diff --git a/appveyor.yml b/appveyor.yml index a6b56670dd..e82bb2968a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -249,7 +249,7 @@ for: cd build echo --- Run CMake Configure ----------------------------------------------------------------------------- cmake --version - cmake -G "$CMAKE_GENERATOR" "-DCMAKE_PREFIX_PATH=$QTDIR;$CIMG_INCLUDE_DIR" "-DCMAKE_INSTALL_PREFIX=$APPVEYOR_BUILD_FOLDER/install" .. + cmake -G "$CMAKE_GENERATOR" "-DCMAKE_PREFIX_PATH=$QTDIR;$CIMG_INCLUDE_DIR" "-DCMAKE_INSTALL_PREFIX=$APPVEYOR_BUILD_FOLDER/install" "-DCMAKE_BUILD_TYPE=$BUILD_CONFIG" .. echo --- Build using CMake ------------------------------------------------------------------------------- cmake --build . --config "$BUILD_CONFIG" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS @@ -260,7 +260,7 @@ for: cd build echo --- Run CMake Configure with FetchCOntent ----------------------------------------------------------- cmake --version - cmake -G "$CMAKE_GENERATOR" "-DCMAKE_PREFIX_PATH=$QTDIR;$CIMG_INCLUDE_DIR" "-DCMAKE_INSTALL_PREFIX=$APPVEYOR_BUILD_FOLDER/install" .. + cmake -G "$CMAKE_GENERATOR" "-DCMAKE_PREFIX_PATH=$QTDIR;$CIMG_INCLUDE_DIR" "-DCMAKE_BUILD_TYPE=$BUILD_CONFIG" "-DCMAKE_INSTALL_PREFIX=$APPVEYOR_BUILD_FOLDER/install" .. echo --- Build using CMake with FetchCOntent ------------------------------------------------------------- cmake --build . --config "$BUILD_CONFIG" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS fi @@ -291,7 +291,7 @@ for: cd examples/cmake_link_example mkdir build cd build - cmake -G "$CMAKE_GENERATOR" "-DCMAKE_PREFIX_PATH=$QTDIR;$CIMG_INCLUDE_DIR;$APPVEYOR_BUILD_FOLDER/install" .. + cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_CONFIG" "-DCMAKE_PREFIX_PATH=$QTDIR;$CIMG_INCLUDE_DIR;$APPVEYOR_BUILD_FOLDER/install" .. cmake --build . --config "$BUILD_CONFIG" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS cd .. fi @@ -342,7 +342,7 @@ for: - sh: cd build - sh: echo --- Run CMake Configure ----------------------------------------------------------------------------- - sh: cmake --version - - sh: cmake -G "$CMAKE_GENERATOR" "-DCMAKE_PREFIX_PATH=$QTDIR" "-DCMAKE_INSTALL_PREFIX=$APPVEYOR_BUILD_FOLDER/install" .. .. + - sh: cmake -G "$CMAKE_GENERATOR" "-DCMAKE_PREFIX_PATH=$QTDIR" "-DCMAKE_BUILD_TYPE=$BUILD_CONFIG" "-DCMAKE_INSTALL_PREFIX=$APPVEYOR_BUILD_FOLDER/install" .. .. - sh: echo --- Build using CMake ------------------------------------------------------------------------------- - sh: cmake --build . --config "$BUILD_CONFIG" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS - sh: | @@ -362,7 +362,7 @@ for: cd examples/cmake_link_example mkdir build cd build - cmake -G "$CMAKE_GENERATOR" "-DCMAKE_PREFIX_PATH=$QTDIR;$CIMG_INCLUDE_DIR;$APPVEYOR_BUILD_FOLDER/install" .. + cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_CONFIG" "-DCMAKE_PREFIX_PATH=$QTDIR;$CIMG_INCLUDE_DIR;$APPVEYOR_BUILD_FOLDER/install" .. cmake --build . --config "$BUILD_CONFIG" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS cd .. fi diff --git a/cmake/jkqtplotter_cmake_options.cmake b/cmake/jkqtplotter_cmake_options.cmake index c3567e0d3d..371a7a32c9 100644 --- a/cmake/jkqtplotter_cmake_options.cmake +++ b/cmake/jkqtplotter_cmake_options.cmake @@ -47,6 +47,17 @@ if(NOT DEFINED CMAKE_INSTALL_PREFIX) option(CMAKE_INSTALL_PREFIX "Install directory" ${CMAKE_CURRENT_SOURCE_DIR}/install) endif() +set(jkqtplotter_default_build_type "Debug") +get_property(JKQtPlotter_isMultiConfigGenerator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT JKQtPlotter_isMultiConfigGenerator) + if(NOT CMAKE_BUILD_TYPE) + warning(STATUS "Setting build type to '${jkqtplotter_default_build_type}' as none was specified.") + set(CMAKE_BUILD_TYPE ${jkqtplotter_default_build_type} CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") + endif() +endif() + + include(GNUInstallDirs) #evaluate the settings above @@ -83,3 +94,4 @@ if(JKQtPlotter_BUILD_LIB_JKQTPLOTTER) set(JKQtPlotter_BUILD_LIB_JKQTMATH "ON") set(JKQtPlotter_BUILD_LIB_JKQTMATHTEXT "ON") endif() + diff --git a/doc/dox/buildinstructions_cmake.dox b/doc/dox/buildinstructions_cmake.dox index 78cfef3747..083f68cc8c 100644 --- a/doc/dox/buildinstructions_cmake.dox +++ b/doc/dox/buildinstructions_cmake.dox @@ -19,9 +19,9 @@ The first step is to configure the bild,using: \code{.sh} $ mkdir build $ cd build - $ cmake .. -G "" "-DCMAKE_PREFIX_PATH=" + $ cmake -G "" "-DCMAKE_PREFIX_PATH=" "-DCMAKE_BUILD_TYPE=Debug" .. \endcode -This configures the CMake build. The Parameter \c tells CMake, which build-file generator to use (e.g. use MinGW Makefiles for MinGW Makefiles on Windows or Unix Makefiles on Unix, see https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html for a list of available generators). The parameter \c should be the path to your Qt installation. You can also add (separated by semicolon) paths to other libraries that JKQTPlotter should use, e.g. CImg or OpenCV. JKQTPlotter does not have any neccessary dependencies, apart from Qt5 or 6, but it contains binding code to somme popular 3rd party libraries (as e.g. CImmg or OpenCV). Also see \ref page_buildinstructions_CMAKE_CONFIG for a listing of additional configuration options for JKQTPlotter. You might e.g. want to set \c CMAKE_INSTALL_PREFIX to a path in which you want to install the build results. This also has to be done at this stage. +This configures the CMake build. The Parameter \c tells CMake, which build-file generator to use (e.g. use MinGW Makefiles for MinGW Makefiles on Windows or Unix Makefiles on Unix, see https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html for a list of available generators). For single-configuration generators (e.g. Unix Makefiles, ..., as opposed to multi-config, like \c Ninja, \c XCode or Visual Studio) you will have to explicitly set the build type using \c -DCMAKE_BUILD_TYPE=Debug (note, you can choose any other allowed build type instead of \c Debug, as e.g. \c Release or \c RelWithDepInfo ). The parameter \c should be the path to your Qt installation. You can also add (separated by semicolon) paths to other libraries that JKQTPlotter should use, e.g. CImg or OpenCV. JKQTPlotter does not have any neccessary dependencies, apart from Qt5 or 6, but it contains binding code to somme popular 3rd party libraries (as e.g. CImmg or OpenCV). Also see \ref page_buildinstructions_CMAKE_CONFIG for a listing of additional configuration options for JKQTPlotter. You might e.g. want to set \c CMAKE_INSTALL_PREFIX to a path in which you want to install the build results. This also has to be done at this stage. Of course you can also perform this step in the CMake GUI or ccmake. @@ -38,7 +38,7 @@ For Visual Studio / Visual C++ the build looks similar, but you will have to sel \code{.sh} $ mkdir build $ cd build - $ cmake .. -G "Visual Studio 16 2019 Win64" "-DCMAKE_PREFIX_PATH=" + $ cmake -G "Visual Studio 16 2019 Win64" "-DCMAKE_PREFIX_PATH=" .. \endcode Where \c \ could be e.g. \c C:/Qt/6.5.0/msvc2019_64 . This call results in a Visual Studio solution \c build/JKQTPlotter.sln that you can load and compile from the Visual Studio IDE. Alternatively you can also build the solution directly calling: diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index ab466cc7bb..90901298b6 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -7,6 +7,12 @@ message( STATUS "=============================================================== message( STATUS "== JKQTPlotterLib Build Information ==" ) message( STATUS "=============================================================================" ) message( STATUS "Version: ${PROJECT_VERSION}") +message( STATUS "CMake Generator: ${CMAKE_GENERATOR}") +if (${JKQtPlotter_isMultiConfigGenerator}) + message( STATUS " is multi-config: YES") +else() + message( STATUS " is multi-config: NO") +endif() message( STATUS "Build type: ${CMAKE_BUILD_TYPE}") message( STATUS "Build types: ${CMAKE_CONFIGURATION_TYPES}") message( STATUS "Build shared lib: ${BUILD_SHARED_LIBS}")