From e44b08da7554e4808a6c5d06be25f141803084b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20Wyszy=C5=84ski?= Date: Wed, 18 Sep 2019 21:42:30 +0200 Subject: [PATCH] Fix CMakes Prefix options with RTTR_ and if it's added as a subdirectory, turn everything off (examples, docs, etc.) --- .appveyor.yml | 26 +++--- .travis.yml | 62 ++++++------- CMake/3rd_party_libs.cmake | 4 +- CMake/config.cmake | 50 +++++------ CMake/installer.cmake | 12 +-- CMake/utility.cmake | 80 ++++++++--------- CMakeLists.txt | 76 +++++++++++----- doc/CMakeLists.txt | 22 ++--- doc/md_pages/building_install.md | 22 ++--- src/CMakeLists.txt | 6 +- src/benchmarks/bench_method/CMakeLists.txt | 24 ++--- src/benchmarks/bench_rttr_cast/CMakeLists.txt | 22 ++--- src/benchmarks/bench_variant/CMakeLists.txt | 20 ++--- .../json_serialization/CMakeLists.txt | 4 +- .../library_loader_example/CMakeLists.txt | 6 +- .../plugin_example/CMakeLists.txt | 6 +- src/examples/scripting/CMakeLists.txt | 6 +- src/rttr/CMakeLists.txt | 87 +++++++++---------- src/unit_tests/CMakeLists.txt | 12 +-- src/unit_tests/base_library/CMakeLists.txt | 6 +- src/unit_tests/plugin/CMakeLists.txt | 6 +- 21 files changed, 294 insertions(+), 265 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 721f3eff..f7dfbe38 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -57,13 +57,13 @@ environment: TESTS_ONLY: true - COMPILER: MSVC_14 ARCHITECTURE: x64 - BUILD_EXAMPLES: true - BUILD_BENCHMARKS: true + RTTR_BUILD_EXAMPLES: true + RTTR_BUILD_BENCHMARKS: true APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - # uncheck this in order to build and upload the documentation + # uncheck this in order to build and upload the documentation #- COMPILER: MSVC_14 # ARCHITECTURE: x64 - # BUILD_DOCU: true + # RTTR_BUILD_DOCU: true # APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 build: @@ -85,12 +85,12 @@ install: - 7z x ninja.zip -oC:\projects\deps\ninja > nul - set PATH=C:\projects\deps\ninja;%PATH% - ninja --version - + ####################################################################################### # Install doxygen ####################################################################################### - ps: >- - If ($env:BUILD_DOCU -Match "true") { + If ($env:RTTR_BUILD_DOCU -Match "true") { $env:DOXYGEN_URL="http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.10.windows.bin.zip" appveyor DownloadFile $env:DOXYGEN_URL -FileName doxygen.zip 7z x doxygen.zip -oC:/projects/deps/doxygen-1.8.10 > $null @@ -102,7 +102,7 @@ install: # CMake ####################################################################################### - cmake --version - + ####################################################################################### # setup boost ####################################################################################### @@ -120,17 +120,17 @@ before_build: - IF "%ARCHITECTURE%" == "x86" IF "%COMPILER%" == "MINGW_482" set PATH=C:\Qt\Tools\mingw482_32\bin;%PATH% - IF "%ARCHITECTURE%" == "x86" IF "%COMPILER%" == "MINGW_492" set PATH=C:\Qt\Tools\mingw492_32\bin;%PATH% - IF "%ARCHITECTURE%" == "x64" IF "%COMPILER%" == "MINGW_W64" set PATH=C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH% - - IF "%BUILD_DOCU%" == "true" choco install lftp --version 4.7.5 - + - IF "%RTTR_BUILD_DOCU%" == "true" choco install lftp --version 4.7.5 + ####################################################################################### # we can use Ninja for all configurations ####################################################################################### build_script: - mkdir build - cd build - - cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=%BUILD_EXAMPLES% -DBUILD_BENCHMARKS=%BUILD_BENCHMARKS% -DBUILD_WEBSITE_DOCU=%BUILD_DOCU% + - cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DRTTR_BUILD_EXAMPLES=%RTTR_BUILD_EXAMPLES% -DRTTR_BUILD_BENCHMARKS=%RTTR_BUILD_BENCHMARKS% -DRTTR_BUILD_WEBSITE_DOCU=%RTTR_BUILD_DOCU% - if "%TESTS_ONLY%" == "true" (ninja run_tests) - - if "%BUILD_EXAMPLES%" == "true" (ninja examples) - - if "%BUILD_BENCHMARKS%" == "true" (ninja bench_method && ninja bench_rttr_cast && ninja bench_variant) + - if "%RTTR_BUILD_EXAMPLES%" == "true" (ninja examples) + - if "%RTTR_BUILD_BENCHMARKS%" == "true" (ninja bench_method && ninja bench_rttr_cast && ninja bench_variant) # when APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH is empty, we knew, we are on master branch - - if "%BUILD_DOCU%" == "true" ( if "%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" == "" (ninja doc_website && echo "Upload documentation..." && lftp -c "set ssl:verify-certificate no; open -u %FTP_USER%,%FTP_PASSWORD% ftp://server3.febas.net:21/; mirror -R doc_website/master doc_tmp" && lftp -c "set ssl:verify-certificate no; open -u %FTP_USER%,%FTP_PASSWORD% ftp://server3.febas.net:21/; rm -r doc" && lftp -c "set ssl:verify-certificate no; open -u %FTP_USER%,%FTP_PASSWORD% ftp://server3.febas.net:21/; mv doc_tmp doc") ) + - if "%RTTR_BUILD_DOCU%" == "true" ( if "%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" == "" (ninja doc_website && echo "Upload documentation..." && lftp -c "set ssl:verify-certificate no; open -u %FTP_USER%,%FTP_PASSWORD% ftp://server3.febas.net:21/; mirror -R doc_website/master doc_tmp" && lftp -c "set ssl:verify-certificate no; open -u %FTP_USER%,%FTP_PASSWORD% ftp://server3.febas.net:21/; rm -r doc" && lftp -c "set ssl:verify-certificate no; open -u %FTP_USER%,%FTP_PASSWORD% ftp://server3.febas.net:21/; mv doc_tmp doc") ) diff --git a/.travis.yml b/.travis.yml index 2b1bc699..037703ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,13 +33,13 @@ env: global: - ARCH_FLAGS_x86='-m32' - ARCH_FLAGS_x86_64='' - - BUILD_DOCU=false + - RTTR_BUILD_DOCU=false - secure: "k1o939GwFc0AJY8cCprAeF9OYUs00Ad+ggrhzxtw4GLdjn0CYGnqrftHtkJ5WySDXj7rnEL4qur1oO19OeVGufhLQTV0+yian8meYppk7rlPIOOl6ygltTxMxNgvmkqCsHC1J1l+7vMEJUm1MunWedCnORWySoK2pZ89nAiMmzY/fjpsOKR8vpXQw5BTZPR775lYZyzbm8/ZY8eATd4EJGH+4YH/sTzYFa9SL2J/ieWR+SvALNLos7x6Civ0Nl6LXx5hXMenpSUpAbu7wBm6KDoL6vGHYa7oKrnJ5BAqOP4poNXF000riy3TENSO1sf+dGQJO8O2IQwe352VKw+paQ4s0SGe5lWAmn2hexU+dZ7rNO0LwA+bdt8XGIXZo2lvdHgsO2Ymj/wPLrqYHGwBgGceBilyD7ZAcKQ/OvHmvkHCytMSVhftcllsOZFwDen/5FliNTRI+Cs68pZUiT2PgT44t/8i5X3F1o8FlV9T+wDsPdH909g/pOFt4U3N8aGxst9bmrQvYAhVmPKtuxjz7ycBfsOTxON9HfTQFEGv3KCREdN8lzi/J9FBCFTtIwHbBKvEeaXrZ3oHSa9UoVG5VQtw14aBdzs7K2MrEYMxg4LCfSHe8ecYbRg1LM9uSdK5dcn/A9wLKEdFmU/pvbl3ryaF4KpL7w0fvNMC/k6o5tc=" - secure: "1ogFHnhUroT3nA1HxyXN5/Hoek6LcTazRPTGpYjKAge8To/x614D6R9j2yu0EDOZalolq0VeOONnHLnss6aPGeMvvHH1rvoKTDQsFjsm1fB6qLRr/qpZXs+G4mxStarxrXr5487hEkPP10fEi/PSOx8Gme6Kny+tXHxDzP04ljcZYVvxWfkb+cQBCnYupbHk4hzfKRmPYcUn6lCPyOGIzwsHQQI/LubmkiU+wQ0zcLLsTZSThk+zt6FlxYWykZGL24yrqmoXRszx8dR14cWPzvkxVeEOe3OY9mNix1Z7ki2eVeEk8m7d70yPmV5p8F2/nPGC7kUXTvPrAL62CcE5moHubijJwKXJM6nBQJYCPGygnvRnWxnoqO/9JpDuds4Cv+tbJMgo2ViLPsYk3BgMnYo4z+p4JViN9P4/jzbhsVtWd4rnXmPt9j4FkED+Eyt8BUzXFdTAPpuzwZSvmYzzR8MdZE/telCAcWUoiS35IQcWJ0UmPpNZfR1Lll0cWQ+dTmjNETJvwognuaTAexL7m0uMhX6KQIZfap2H0w+CIua7+jl6eb9iyvXv9vZZEUCH2kTWnYXqBmDGRHG3tEp97o5+yWQm1qjweLvKAMRirdkSaZEL0lrsJ8mBS6Y+PQwAQxlu+P3pFEJ6uU3fJrKyciuWnVDZKyddIrJEZorXjOA=" matrix: include: - + # check code formatting - os: linux compiler: gcc @@ -47,7 +47,7 @@ matrix: addons: apt: packages: ['vera++'] - + # valgrind memory check - os: linux compiler: gcc @@ -68,7 +68,7 @@ matrix: - pip install --user urllib3[secure] cpp-coveralls - coveralls -e 3rd_party -e src/benchmarks -e src/unit_tests -i src/rttr --gcov-options '\-lp' --gcov 'gcov-4.8' env: NAME="code coverage x86" COMPILER=g++-4.8 ARCH=x86 CONF=Debug GCOV_FLAGS='--coverage' UNIT_TESTS=true - + # check code coverage x64 => result https://coveralls.io/github/rttrorg/rttr - os: linux compiler: gcc @@ -80,7 +80,7 @@ matrix: - pip install --user urllib3[secure] cpp-coveralls - coveralls -e 3rd_party -e src/benchmarks -e src/unit_tests -i src/rttr --gcov-options '\-lp' --gcov 'gcov-4.8' env: NAME="code coverage x64" COMPILER=g++-4.8 ARCH=x86_64 CONF=Debug GCOV_FLAGS='--coverage' UNIT_TESTS=true - + # build docu and upload to server - os: linux compiler: gcc @@ -97,7 +97,7 @@ matrix: lftp -c "set ssl:verify-certificate no; open -u ${FTP_USER},${FTP_PASSWORD} ftp://server3.febas.net:21/; rm -r doc" lftp -c "set ssl:verify-certificate no; open -u ${FTP_USER},${FTP_PASSWORD} ftp://server3.febas.net:21/; mv doc_tmp doc" fi - env: NAME="documentation build" BUILD_DOCU=true COMPILER=g++-4.8 ARCH=x86 CONF=Release UNIT_TESTS=false + env: NAME="documentation build" RTTR_BUILD_DOCU=true COMPILER=g++-4.8 ARCH=x86 CONF=Release UNIT_TESTS=false # Linux / GCC - os: linux @@ -123,15 +123,15 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: ['g++-5', 'ninja-build'] env: NAME="g++-5" COMPILER=g++-5 ARCH=x86_64 CONF=Release UNIT_TESTS=true - + - os: linux compiler: gcc addons: apt: sources: ['ubuntu-toolchain-r-test'] packages: ['g++-5', 'libboost-all-dev', 'ninja-build'] - env: NAME="g++-5 - Build benchmarks & examples" COMPILER=g++-5 ARCH=x86_64 CONF=Release UNIT_TESTS=true BUILD_EXAMPLES=true BUILD_BENCHMARKS=true - + env: NAME="g++-5 - Build benchmarks & examples" COMPILER=g++-5 ARCH=x86_64 CONF=Release UNIT_TESTS=true RTTR_BUILD_EXAMPLES=true RTTR_BUILD_BENCHMARKS=true + - os: linux compiler: gcc addons: @@ -139,15 +139,15 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: ['g++-6', 'ninja-build'] env: NAME="g++-6" COMPILER=g++-6 ARCH=x86_64 CONF=Release UNIT_TESTS=true - + - os: linux compiler: gcc addons: apt: sources: ['ubuntu-toolchain-r-test'] packages: ['g++-7', 'libboost-all-dev', 'ninja-build'] - env: NAME="g++-7" COMPILER=g++-7 ARCH=x86_64 CONF=Release UNIT_TESTS=true BUILD_BENCHMARKS=true - + env: NAME="g++-7" COMPILER=g++-7 ARCH=x86_64 CONF=Release UNIT_TESTS=true RTTR_BUILD_BENCHMARKS=true + # Linux / CLang - os: linux compiler: clang @@ -156,15 +156,15 @@ matrix: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7'] packages: ['libstdc++-5-dev', 'clang-3.7', 'ninja-build'] env: COMPILER=clang++-3.7 ARCH=x86_64 CONF=Release UNIT_TESTS=true - + - os: linux compiler: clang addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0'] packages: ['libstdc++-6-dev', 'clang-4.0', 'libboost-all-dev', 'ninja-build'] - env: NAME="clang++-4.0 - build benchmarks & examples" COMPILER=clang++-4.0 ARCH=x86_64 CONF=Release UNIT_TESTS=false BUILD_EXAMPLES=true BUILD_BENCHMARKS=true - + env: NAME="clang++-4.0 - build benchmarks & examples" COMPILER=clang++-4.0 ARCH=x86_64 CONF=Release UNIT_TESTS=false RTTR_BUILD_EXAMPLES=true RTTR_BUILD_BENCHMARKS=true + - os: linux compiler: clang addons: @@ -172,7 +172,7 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: ['libstdc++-5-dev', 'clang-3.8', 'ninja-build'] env: COMPILER=clang++-3.8 ARCH=x86_64 CONF=Release UNIT_TESTS=true - + - os: linux compiler: clang addons: @@ -180,7 +180,7 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: ['libstdc++-6-dev', 'clang-3.9', 'ninja-build'] env: COMPILER=clang++-3.9 ARCH=x86_64 CONF=Release UNIT_TESTS=true - + - os: linux compiler: clang addons: @@ -188,7 +188,7 @@ matrix: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0'] packages: ['libstdc++-6-dev', 'clang-4.0', 'ninja-build'] env: COMPILER=clang++-4.0 ARCH=x86_64 CONF=Release UNIT_TESTS=true - + - os: linux compiler: clang addons: @@ -201,8 +201,8 @@ matrix: - os: osx osx_image: xcode9.2 compiler: clang - env: COMPILER=clang++ ARCH=x86 CONF=Release UNIT_TESTS=true BUILD_BENCHMARKS=true BUILD_EXAMPLES=true - + env: COMPILER=clang++ ARCH=x86 CONF=Release UNIT_TESTS=true RTTR_BUILD_BENCHMARKS=true RTTR_BUILD_EXAMPLES=true + - os: osx osx_image: xcode9.2 compiler: clang @@ -217,15 +217,15 @@ matrix: osx_image: xcode8.3 compiler: clang env: COMPILER=clang++ ARCH=x86 CONF=Release UNIT_TESTS=true - + - os: osx osx_image: xcode8.3 compiler: clang env: COMPILER=clang++ ARCH=x86_64 CONF=Release UNIT_TESTS=true allow_failures: - - env: NAME="documentation build" BUILD_DOCU=true COMPILER=g++-4.8 ARCH=x86 CONF=Release UNIT_TESTS=false - + - env: NAME="documentation build" RTTR_BUILD_DOCU=true COMPILER=g++-4.8 ARCH=x86 CONF=Release UNIT_TESTS=false + before_install: - export CIT_ROOT=`pwd` - cd $CIT_ROOT @@ -256,12 +256,12 @@ install: # Install recent Doxygen ####################################################################################### - | - if [[ "${BUILD_DOCU}" == "true" ]]; then + if [[ "${RTTR_BUILD_DOCU}" == "true" ]]; then DOXYGEN_URL="http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.10.linux.bin.tar.gz" mkdir doxygen && travis_retry wget --quiet -O - ${DOXYGEN_URL} | tar --strip-components=1 -xz -C doxygen export PATH=${DEPS_DIR}/doxygen/bin:${PATH} fi - + before_script: - cd ${TRAVIS_BUILD_DIR} - mkdir build @@ -271,9 +271,9 @@ before_script: -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${CONF} -DCMAKE_CXX_FLAGS="$ARCH_FLAGS $CMAKE_ADDITIONAL_FLAGS $GCOV_FLAGS" - -DBUILD_WEBSITE_DOCU=$BUILD_DOCU - -DBUILD_EXAMPLES=$BUILD_EXAMPLES - -DBUILD_BENCHMARKS=$BUILD_BENCHMARKS + -DRTTR_BUILD_WEBSITE_DOCU=$RTTR_BUILD_DOCU + -DRTTR_BUILD_EXAMPLES=$RTTR_BUILD_EXAMPLES + -DRTTR_BUILD_BENCHMARKS=$RTTR_BUILD_BENCHMARKS ..) script: @@ -297,17 +297,17 @@ script: (cd build && make run_tests -j2) fi - | - if [[ "${BUILD_DOCU}" == "true" ]]; then + if [[ "${RTTR_BUILD_DOCU}" == "true" ]]; then # Run unit tests on two cores (cd build && make doc_website -j2) fi - | - if [[ "${BUILD_BENCHMARKS}" == "true" ]]; then + if [[ "${RTTR_BUILD_BENCHMARKS}" == "true" ]]; then # Run unit tests on two cores (cd build && make bench_method -j2 && make bench_rttr_cast -j2 && make bench_variant -j2) fi - | - if [[ "${BUILD_EXAMPLES}" == "true" ]]; then + if [[ "${RTTR_BUILD_EXAMPLES}" == "true" ]]; then # Run unit tests on two cores (cd build && make examples) fi diff --git a/CMake/3rd_party_libs.cmake b/CMake/3rd_party_libs.cmake index e5965f8f..cca06f38 100644 --- a/CMake/3rd_party_libs.cmake +++ b/CMake/3rd_party_libs.cmake @@ -34,7 +34,7 @@ MESSAGE(STATUS ${LIBRARY_OUTPUT_DIRECTORY}) MESSAGE(STATUS "Finding 3rd party libs...") MESSAGE(STATUS "===========================") -if (BUILD_BENCHMARKS) +if (RTTR_BUILD_BENCHMARKS) if (MSVC) # there is a the moment a problem with finding multiple versions of boost, # i.e. the static AND the static runtime version; that is not possible atm. @@ -49,7 +49,7 @@ if (BUILD_BENCHMARKS) endif() endif() -if (BUILD_BENCHMARKS OR BUILD_EXAMPLES) +if (RTTR_BUILD_BENCHMARKS OR RTTR_BUILD_EXAMPLES) find_package(Threads REQUIRED) endif() diff --git a/CMake/config.cmake b/CMake/config.cmake index 1b692f50..7f6a29f0 100644 --- a/CMake/config.cmake +++ b/CMake/config.cmake @@ -36,8 +36,8 @@ set(RTTR_PRODUCT_NAME "RTTR") message("Project version: ${RTTR_VERSION_STR}") # files -set(README_FILE "${CMAKE_SOURCE_DIR}/README.md") -set(LICENSE_FILE "${CMAKE_SOURCE_DIR}/LICENSE.txt") +set(README_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") +set(LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") # dirs where the binaries should be placed, installed set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") @@ -46,7 +46,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") set(CMAKE_EXECUTABLE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") # here we specify the installation directory -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) +if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/install" CACHE PATH "RTTR install prefix" FORCE) endif() @@ -60,9 +60,9 @@ getNameOfDir(CMAKE_LIBRARY_OUTPUT_DIRECTORY RTTR_TARGET_BIN_DIR) is_vs_based_build(VS_BUILD) # set all install directories for the targets -if(UNIX) +if (UNIX) include(GNUInstallDirs) - set(RTTR_RUNTIME_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}") + set(RTTR_RUNTIME_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}") set(RTTR_LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") set(RTTR_ARCHIVE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") set(RTTR_FRAMEWORK_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") @@ -72,8 +72,8 @@ if(UNIX) set(RTTR_CMAKE_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/rttr/cmake") set(RTTR_ADDITIONAL_FILES_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/rttr") -elseif(WIN32) - set(RTTR_RUNTIME_INSTALL_DIR "bin") +elseif (WIN32) + set(RTTR_RUNTIME_INSTALL_DIR "bin") set(RTTR_LIBRARY_INSTALL_DIR "bin") set(RTTR_ARCHIVE_INSTALL_DIR "lib") set(RTTR_FRAMEWORK_INSTALL_DIR "bin") @@ -86,20 +86,20 @@ endif() # to avoid a setting a global debug flag automatically for all targets # we use an own variable -set(RTTR_DEBUG_POSTFIX "_d") +set(RTTR_DEBUG_POSTFIX "_d") # set the rpath for executables set(CMAKE_SKIP_BUILD_RPATH OFF) # use, i.e. don't skip the full RPATH for the build tree set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF) # when building, don't use the install RPATH already (but later on when installing) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH OFF) # NO automatic rpath for INSTALL -if(APPLE) +if (APPLE) set(MACOSX_RPATH ON CACHE STRING "Set this to off if you dont want @rpath in install names") # uses a install name @rpath/... for libraries set(RTTR_EXECUTABLE_INSTALL_RPATH "${RTTR_INSTALL_FULL_LIBDIR};@executable_path") # the executable is relocatable, since the library builds with and install name "@rpath/librttr_core.0.9.6.dylib" - # the executable links -elseif(UNIX) + # the executable links +elseif (UNIX) set(RTTR_EXECUTABLE_INSTALL_RPATH "${RTTR_INSTALL_FULL_LIBDIR};$ORIGIN") -elseif(WIN32) +elseif (WIN32) # no such thing as rpath exists set(RTTR_EXECUTABLE_INSTALL_RPATH ${RTTR_INSTALL_BINDIR}) # default, has no effect endif() @@ -116,7 +116,7 @@ endif() # use standard c++ insteaf of extented (-std=c++17 vs. std=gnu++17) set(CMAKE_CXX_EXTENSIONS OFF) -enable_rtti(BUILD_WITH_RTTI) +enable_rtti(RTTR_BUILD_WITH_RTTI) get_latest_supported_cxx(CXX_STANDARD) set(MAX_CXX_STANDARD ${CXX_STANDARD}) @@ -125,36 +125,36 @@ message(STATUS "using C++: ${MAX_CXX_STANDARD}") # RelWithDepInfo should have the same option like the Release build # but of course with Debug informations -if(MSVC) +if (MSVC) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Zi /DEBUG") -elseif(CMAKE_COMPILER_IS_GNUCXX ) +elseif (CMAKE_COMPILER_IS_GNUCXX ) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g") -elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g") else() message(WARNING "Please adjust CMAKE_CXX_FLAGS_RELWITHDEBINFO flags for this compiler!") endif() -if(MSVC) +if (MSVC) # we have to remove the default warning level, - # otherwise we get ugly compiler warnings, because of later replacing + # otherwise we get ugly compiler warnings, because of later replacing # option /W3 with /W4 (which will be later added) - replace_compiler_option("/W3" " ") - if (BUILD_WITH_STATIC_RUNTIME_LIBS) + replace_compiler_option("/W3" " ") + if (RTTR_BUILD_WITH_STATIC_RUNTIME_LIBS) replace_compiler_option("/MD" " ") replace_compiler_option("/MDd" " ") endif() - -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if(MINGW) + +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if (MINGW) set(GNU_STATIC_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") else() set(GNU_STATIC_LINKER_FLAGS "-static-libgcc -static-libstdc++") endif() -elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") +elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CLANG_STATIC_LINKER_FLAGS "-stdlib=libc++ -static-libstdc++") endif() @@ -165,7 +165,7 @@ write_basic_package_version_file( COMPATIBILITY AnyNewerVersion ) -if (BUILD_INSTALLER) +if (RTTR_BUILD_INSTALLER) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/CMake/rttr-config-version.cmake" DESTINATION ${RTTR_CMAKE_CONFIG_INSTALL_DIR} COMPONENT Devel) diff --git a/CMake/installer.cmake b/CMake/installer.cmake index e97d0c3b..7af32de4 100644 --- a/CMake/installer.cmake +++ b/CMake/installer.cmake @@ -26,15 +26,15 @@ #################################################################################### # first step set up all necessary variables -if(WIN32 AND NOT UNIX) +if (WIN32 AND NOT UNIX) if (NOT CMAKE_VERSION VERSION_LESS 3.1.0) set(CPACK_GENERATOR 7Z) else() set(CPACK_GENERATOR ZIP) endif() -elseif(UNIX AND NOT APPLE) +elseif (UNIX AND NOT APPLE) set(CPACK_GENERATOR TGZ;TBZ2) -elseif(APPLE) +elseif (APPLE) set(CPACK_GENERATOR TGZ;TBZ2;PackageMaker) endif() @@ -52,9 +52,9 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_VENDOR}/RTTR") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "RTTR is a C++ runtime reflection library") # detect system -if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(RTTR_OS_NAME "linux${RTTR_NATIVE_ARCH}") -elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows") set(RTTR_OS_NAME "win${RTTR_NATIVE_ARCH}") else() message(WARNING "This system is not supported for packing") @@ -68,4 +68,4 @@ set(CPACK_PACKAGE_FILE_NAME "rttr-${RTTR_VERSION_STR}-${RTTR_OS_NAME}-${RTTR_COM set(CPACK_SOURCE_PACKAGE_FILE_NAME "rttr-${RTTR_VERSION_STR}-src") # now as last step we can include CPack -include(CPack) \ No newline at end of file +include(CPack) diff --git a/CMake/utility.cmake b/CMake/utility.cmake index cd1e835c..a58d5156 100644 --- a/CMake/utility.cmake +++ b/CMake/utility.cmake @@ -47,7 +47,7 @@ function (createSrcGroups FILE_LIST ) string ( REGEX REPLACE "[\\/]" "\\\\" normPath ${curStr} ) string ( REGEX MATCH "\\\\(.*)\\\\" ouput ${normPath} ) - if(NOT CMAKE_MATCH_1 STREQUAL "") + if (NOT CMAKE_MATCH_1 STREQUAL "") source_group ( ${CMAKE_MATCH_1} FILES ${SOURCE} ) endif() endforeach() @@ -153,7 +153,7 @@ function(loadFolder FOLDER _HEADER_FILES _SOURCE_FILES) else() set(FULL_HEADER_PATH ${ABS_PATH_TO_FILES}/${headerFile}) file(STRINGS ${FULL_HEADER_PATH} var REGEX "Q_OBJECT") - if(var) + if (var) list(APPEND QT_MOC_HEADERS ${FULL_HEADER_PATH}) endif() @@ -232,7 +232,7 @@ endfunction() # _INPUT This variable will be set to TRUE if its a Visual Studio build, otherwise to FALSE. #################################################################################### function (is_vs_based_build _INPUT) - if(${CMAKE_GENERATOR} MATCHES "Visual Studio") + if (${CMAKE_GENERATOR} MATCHES "Visual Studio") set(${_INPUT} TRUE PARENT_SCOPE) else() set(${_INPUT} FALSE PARENT_SCOPE) @@ -250,8 +250,8 @@ function(copy_dependency_release _INPUT _OUTPUT) is_vs_based_build(VS_BUILD) # when this is a DEBUG build we dont copy the files - if(NOT VS_BUILD) - if(${CMAKE_BUILD_TYPE} STREQUAL Debug) + if (NOT VS_BUILD) + if (${CMAKE_BUILD_TYPE} STREQUAL Debug) return() endif() endif() @@ -302,8 +302,8 @@ function(copy_dependency_debug _INPUT _OUTPUT) is_vs_based_build(VS_BUILD) # when this is NOT a DEBUG build we dont copy the files - if(NOT VS_BUILD) - if(NOT ${CMAKE_BUILD_TYPE} STREQUAL Debug) + if (NOT VS_BUILD) + if (NOT ${CMAKE_BUILD_TYPE} STREQUAL Debug) return() endif() endif() @@ -352,10 +352,10 @@ function(activate_precompiled_headers _PRECOMPILED_HEADER _SOURCE_FILES) set(pch_abs ${CMAKE_CURRENT_SOURCE_DIR}/${_PRECOMPILED_HEADER}) set(pch_unity ${CMAKE_CURRENT_BINARY_DIR}/${pch_basename}.cpp) - if(MSVC) + if (MSVC) # First specify the name of the PCH file # it seems to be that nmake build cant handle the $(IntDir) variable - if(NOT MSVC_IDE) + if (NOT MSVC_IDE) set(pch_bin ${CMAKE_CURRENT_BINARY_DIR}/${pch_basename}.pch) else() set(pch_bin "$(IntDir)/${pch_basename}.pch") @@ -391,18 +391,18 @@ endfunction() # target Target name #################################################################################### function( set_compiler_warnings target) - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(WARNINGS "-Werror" "-Wall") - elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(WARNINGS "-Werror" "-Wall") - elseif(MSVC) + elseif (MSVC) set(WARNINGS "/WX" "/W4") endif() - target_compile_options(${target} PRIVATE ${WARNINGS}) + target_compile_options(${target} PRIVATE ${WARNINGS}) endfunction() #################################################################################### @@ -414,7 +414,7 @@ function( replace_compiler_option _OLD_OPTION _NEW_OPTION) foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - if(${flag_var} MATCHES ${_OLD_OPTION}) + if (${flag_var} MATCHES ${_OLD_OPTION}) # the whitespace after_OLD_OPTION is necessary to really match only the flag and not some sub flag (/MD should match by /MDd) string(REGEX REPLACE "${_OLD_OPTION} " "${_NEW_OPTION} " ${flag_var} "${${flag_var}}") else() @@ -434,10 +434,10 @@ macro(enable_rtti _ENABLE) if (MSVC) set(enable_rtti_opt "/GR") set(disable_rtti_opt "/GR-") - elseif(CMAKE_COMPILER_IS_GNUCXX ) + elseif (CMAKE_COMPILER_IS_GNUCXX ) set(enable_rtti_opt "-frtti") set(disable_rtti_opt "-fno-rtti") - elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(enable_rtti_opt "-frtti") set(disable_rtti_opt "-fno-rtti") else() @@ -459,28 +459,28 @@ endmacro() # _COMPILER_NAME #################################################################################### function(getCompilerName _COMPILER_NAME) - if(MSVC_VERSION EQUAL 1400) + if (MSVC_VERSION EQUAL 1400) set(COMPILER_NAME "vs2005") - elseif(MSVC_VERSION EQUAL 1500) + elseif (MSVC_VERSION EQUAL 1500) set(COMPILER_NAME "vs2008") - elseif(MSVC_VERSION EQUAL 1600) + elseif (MSVC_VERSION EQUAL 1600) set(COMPILER_NAME "vs2010") - elseif(MSVC_VERSION EQUAL 1700) + elseif (MSVC_VERSION EQUAL 1700) set(COMPILER_NAME "vs2012") - elseif(MSVC_VERSION EQUAL 1800) + elseif (MSVC_VERSION EQUAL 1800) set(COMPILER_NAME "vs2013") - elseif(MSVC_VERSION EQUAL 1900) + elseif (MSVC_VERSION EQUAL 1900) set(COMPILER_NAME "vs2015") - elseif((MSVC_VERSION EQUAL 1910 OR MSVC_VERSION GREATER 1910) AND (MSVC_VERSION EQUAL 1919 OR MSVC_VERSION LESS 1919)) + elseif ((MSVC_VERSION EQUAL 1910 OR MSVC_VERSION GREATER 1910) AND (MSVC_VERSION EQUAL 1919 OR MSVC_VERSION LESS 1919)) set(COMPILER_NAME "vs2017") - elseif(CMAKE_COMPILER_IS_GNUCXX) + elseif (CMAKE_COMPILER_IS_GNUCXX) set(COMPILER_NAME "gcc") - if(WIN32) + if (WIN32) execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT) string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" GCC_VERSION "${GCC_VERSION_OUTPUT}") set(COMPILER_NAME ${COMPILER_NAME}${GCC_VERSION}) endif() - elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(COMPILER_NAME "clang") else() message(WARNING "Can not retrieve compiler name!") @@ -530,13 +530,13 @@ function(get_latest_supported_cxx CXX_STANDARD) if (POLICY CMP0067) cmake_policy(SET CMP0067 NEW) endif() - + # we need to set CMAKE_CXX_STANDARD in order to use the flags for 'check_cxx_source_compiles' - if(${CMAKE_VERSION} VERSION_LESS "3.8.0") + if (${CMAKE_VERSION} VERSION_LESS "3.8.0") set(CMAKE_CXX_STANDARD 14) else() set(CMAKE_CXX_STANDARD 17) - endif() + endif() include(CheckCXXSourceCompiles) @@ -544,12 +544,12 @@ function(get_latest_supported_cxx CXX_STANDARD) #include typedef void F(); typedef void G() noexcept; - + std::enable_if< !std::is_same::value, int >::type i = 42; - + int main() { return 0; } " HAS_NO_EXCEPT_TYPE_SIGNATURE_SUPPORT) @@ -563,34 +563,34 @@ function(get_latest_supported_cxx CXX_STANDARD) static_assert(std::is_member_function_pointer::value, \"Failed\"); } int main() { test_func(&foo::func); return 0; } - " + " HAS_STL_NO_EXCEPT_TYPE_SIGNATURE_SUPPORT) - + check_cxx_source_compiles(" constexpr int abs(int x) { if(x < 0) x = -x; return x; } - + int main() { } " HAS_CXX_CONSTEXPR) - + check_cxx_source_compiles( " #include template struct template_type_trait : std::false_type {}; - + template