ensure that either CMAKE_BUILD_TYPE or CMAKE_CONFIGURATION_TYPES is set in CMake

This commit is contained in:
jkriege2 2024-01-27 14:20:31 +01:00
parent 16d44d6a63
commit bcbce121c1
4 changed files with 26 additions and 8 deletions

View File

@ -249,7 +249,7 @@ for:
cd build cd build
echo --- Run CMake Configure ----------------------------------------------------------------------------- echo --- Run CMake Configure -----------------------------------------------------------------------------
cmake --version 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 ------------------------------------------------------------------------------- echo --- Build using CMake -------------------------------------------------------------------------------
cmake --build . --config "$BUILD_CONFIG" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS cmake --build . --config "$BUILD_CONFIG" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS
@ -260,7 +260,7 @@ for:
cd build cd build
echo --- Run CMake Configure with FetchCOntent ----------------------------------------------------------- echo --- Run CMake Configure with FetchCOntent -----------------------------------------------------------
cmake --version 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 ------------------------------------------------------------- echo --- Build using CMake with FetchCOntent -------------------------------------------------------------
cmake --build . --config "$BUILD_CONFIG" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS cmake --build . --config "$BUILD_CONFIG" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS
fi fi
@ -291,7 +291,7 @@ for:
cd examples/cmake_link_example cd examples/cmake_link_example
mkdir build mkdir build
cd 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 cmake --build . --config "$BUILD_CONFIG" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS
cd .. cd ..
fi fi
@ -342,7 +342,7 @@ for:
- sh: cd build - sh: cd build
- sh: echo --- Run CMake Configure ----------------------------------------------------------------------------- - sh: echo --- Run CMake Configure -----------------------------------------------------------------------------
- sh: cmake --version - 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: echo --- Build using CMake -------------------------------------------------------------------------------
- sh: cmake --build . --config "$BUILD_CONFIG" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS - sh: cmake --build . --config "$BUILD_CONFIG" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS
- sh: | - sh: |
@ -362,7 +362,7 @@ for:
cd examples/cmake_link_example cd examples/cmake_link_example
mkdir build mkdir build
cd 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 cmake --build . --config "$BUILD_CONFIG" -j$(getconf _NPROCESSORS_ONLN) -- $CMAKE_BUILDFLAGS
cd .. cd ..
fi fi

View File

@ -47,6 +47,17 @@ if(NOT DEFINED CMAKE_INSTALL_PREFIX)
option(CMAKE_INSTALL_PREFIX "Install directory" ${CMAKE_CURRENT_SOURCE_DIR}/install) option(CMAKE_INSTALL_PREFIX "Install directory" ${CMAKE_CURRENT_SOURCE_DIR}/install)
endif() 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) include(GNUInstallDirs)
#evaluate the settings above #evaluate the settings above
@ -83,3 +94,4 @@ if(JKQtPlotter_BUILD_LIB_JKQTPLOTTER)
set(JKQtPlotter_BUILD_LIB_JKQTMATH "ON") set(JKQtPlotter_BUILD_LIB_JKQTMATH "ON")
set(JKQtPlotter_BUILD_LIB_JKQTMATHTEXT "ON") set(JKQtPlotter_BUILD_LIB_JKQTMATHTEXT "ON")
endif() endif()

View File

@ -19,9 +19,9 @@ The first step is to configure the bild,using:
\code{.sh} \code{.sh}
$ mkdir build $ mkdir build
$ cd build $ cd build
$ cmake .. -G "<GENERATOR>" "-DCMAKE_PREFIX_PATH=<path_to_your_qt_sources>" $ cmake -G "<GENERATOR>" "-DCMAKE_PREFIX_PATH=<path_to_your_qt_sources>" "-DCMAKE_BUILD_TYPE=Debug" ..
\endcode \endcode
This configures the CMake build. The Parameter \c <GENERATOR> tells CMake, which build-file generator to use (e.g. use <code>MinGW Makefiles</code> for MinGW Makefiles on Windows or <code>Unix Makefiles</code> on Unix, see <a href="https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html">https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html</a> for a list of available generators). The parameter \c <path_to_your_qt_sources> 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. <a href="https://cimg.eu/">CImg</a> or <a href="https://cimg.eu/">OpenCV</a>. 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 <GENERATOR> tells CMake, which build-file generator to use (e.g. use <code>MinGW Makefiles</code> for MinGW Makefiles on Windows or <code>Unix Makefiles</code> on Unix, see <a href="https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html">https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html</a> for a list of available generators). For single-configuration generators (e.g. <code>Unix Makefiles</code>, ..., as opposed to multi-config, like \c Ninja, \c XCode or <code>Visual Studio</code>) 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 <path_to_your_qt_sources> 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. <a href="https://cimg.eu/">CImg</a> or <a href="https://cimg.eu/">OpenCV</a>. 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 <a href="https://cmake.org/cmake/help/latest/manual/cmake-gui.1.html">CMake GUI</a> or <a href="https://cmake.org/cmake/help/latest/manual/ccmake.1.html">ccmake</a>. Of course you can also perform this step in the <a href="https://cmake.org/cmake/help/latest/manual/cmake-gui.1.html">CMake GUI</a> or <a href="https://cmake.org/cmake/help/latest/manual/ccmake.1.html">ccmake</a>.
@ -38,7 +38,7 @@ For Visual Studio / Visual C++ the build looks similar, but you will have to sel
\code{.sh} \code{.sh}
$ mkdir build $ mkdir build
$ cd build $ cd build
$ cmake .. -G "Visual Studio 16 2019 Win64" "-DCMAKE_PREFIX_PATH=<path_to_your_qt_sources>" $ cmake -G "Visual Studio 16 2019 Win64" "-DCMAKE_PREFIX_PATH=<path_to_your_qt_sources>" ..
\endcode \endcode
Where \c \<path_to_your_qt_sources\> 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: Where \c \<path_to_your_qt_sources\> 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:

View File

@ -7,6 +7,12 @@ message( STATUS "===============================================================
message( STATUS "== JKQTPlotterLib Build Information ==" ) message( STATUS "== JKQTPlotterLib Build Information ==" )
message( STATUS "=============================================================================" ) message( STATUS "=============================================================================" )
message( STATUS "Version: ${PROJECT_VERSION}") 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 type: ${CMAKE_BUILD_TYPE}")
message( STATUS "Build types: ${CMAKE_CONFIGURATION_TYPES}") message( STATUS "Build types: ${CMAKE_CONFIGURATION_TYPES}")
message( STATUS "Build shared lib: ${BUILD_SHARED_LIBS}") message( STATUS "Build shared lib: ${BUILD_SHARED_LIBS}")