From 4ffa683b6a5fad35ee1a0d78a9ea772208bafb01 Mon Sep 17 00:00:00 2001 From: Gennady Pospelov <g.pospelov@fz-juelich.de> Date: Thu, 15 Nov 2018 18:04:19 +0100 Subject: [PATCH] Move CMake policies in common file --- CMakeLists.txt | 6 +---- Core/CMakeLists.txt | 4 --- Fit/CMakeLists.txt | 4 --- GUI/CMakeLists.txt | 6 ----- GUI/coregui/CMakeLists.txt | 16 ------------ Tests/Functional/GUI/CMakeLists.txt | 7 ------ Tests/Functional/TestMachinery/CMakeLists.txt | 9 ------- Tests/UnitTests/Core/CMakeLists.txt | 8 ------ Tests/UnitTests/Fit/CMakeLists.txt | 8 ------ Tests/UnitTests/GUI/CMakeLists.txt | 8 ------ Tests/UnitTests/Numeric/CMakeLists.txt | 8 ------ ThirdParty/GUI/qcustomplot/CMakeLists.txt | 6 ----- .../GUI/qt-manhattan-style/CMakeLists.txt | 10 -------- ThirdParty/common/gtest/CMakeLists.txt | 4 --- cmake/bornagain/modules/BornAgainPolicy.cmake | 25 +++++++++++++++++++ 15 files changed, 26 insertions(+), 103 deletions(-) create mode 100644 cmake/bornagain/modules/BornAgainPolicy.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d4459b12769..f05c2d9442f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,6 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) -if(APPLE) -if(POLICY CMP0025) - cmake_policy(SET CMP0025 NEW) -endif() -endif() set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/generic/modules @@ -64,6 +59,7 @@ if(ZERO_TOLERANCE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wfatal-errors") endif() include(BornAgainConfiguration) +include(BornAgainPolicy) include(GeneratePythonDocs) include(PyExamplesLineLength) include(CheckCode) diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index 8bc3aa0c18a..26f335c8b2d 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -4,10 +4,6 @@ set(library_name BornAgainCore) -if(POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) -endif() - if(BORNAGAIN_TIDY) # set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=-*,readability-*,-readability-braces-around-statements") set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=-*,clang-analyzer-*,readability-*,-readability-braces-around-statements,modernize-*") diff --git a/Fit/CMakeLists.txt b/Fit/CMakeLists.txt index 346f7d7c019..4b0af5985be 100644 --- a/Fit/CMakeLists.txt +++ b/Fit/CMakeLists.txt @@ -4,10 +4,6 @@ set(library_name BornAgainFit) -if(POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) -endif() - # --- source and include files ------ set(FIT_SOURCE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/Kernel diff --git a/GUI/CMakeLists.txt b/GUI/CMakeLists.txt index ea8ff265f47..69f3895f40c 100644 --- a/GUI/CMakeLists.txt +++ b/GUI/CMakeLists.txt @@ -1,12 +1,6 @@ ############################################################################ # CMakeLists.txt file for building BornAgain/GUI libraries and executable ############################################################################ -if(POLICY CMP0020) - cmake_policy(SET CMP0020 NEW) -endif() -if(POLICY CMP0043) - cmake_policy(SET CMP0043 NEW) -endif() message(STATUS "Configuring BornAgain GUI") diff --git a/GUI/coregui/CMakeLists.txt b/GUI/coregui/CMakeLists.txt index 7c5daf8a233..5caa7bf421c 100644 --- a/GUI/coregui/CMakeLists.txt +++ b/GUI/coregui/CMakeLists.txt @@ -3,22 +3,6 @@ ############################################################################ set(library_name BornAgainGUI) -if(POLICY CMP0020) - cmake_policy(SET CMP0020 NEW) -endif() -if(POLICY CMP0043) - cmake_policy(SET CMP0043 NEW) -endif() -if(POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) -endif() -if(POLICY CMP0028) - cmake_policy(SET CMP0028 NEW) -endif() -if(POLICY CMP0071) - cmake_policy(SET CMP0071 NEW) -endif() - # --- source and include files --- set(include_dirs ${CMAKE_CURRENT_SOURCE_DIR}/mainwindow diff --git a/Tests/Functional/GUI/CMakeLists.txt b/Tests/Functional/GUI/CMakeLists.txt index 8fe5660ce1f..c0a7bdb20fa 100644 --- a/Tests/Functional/GUI/CMakeLists.txt +++ b/Tests/Functional/GUI/CMakeLists.txt @@ -1,10 +1,3 @@ -if(POLICY CMP0020) - cmake_policy(SET CMP0020 NEW) -endif() -if(POLICY CMP0043) - cmake_policy(SET CMP0043 NEW) -endif() - find_package(Qt5Widgets REQUIRED) add_subdirectory(GUIStandardTest) diff --git a/Tests/Functional/TestMachinery/CMakeLists.txt b/Tests/Functional/TestMachinery/CMakeLists.txt index ba4b66229fa..9bf0b1c4db6 100644 --- a/Tests/Functional/TestMachinery/CMakeLists.txt +++ b/Tests/Functional/TestMachinery/CMakeLists.txt @@ -4,10 +4,6 @@ set(library_name BornAgainTestMachinery) -if(POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) -endif() - file(GLOB source_files "*.cpp") file(GLOB include_files "*.h") @@ -41,8 +37,3 @@ if(APPLE AND BORNAGAIN_APPLE_BUNDLE) set(link_flags "-Wl,-rpath,@loader_path/../../Frameworks") set_target_properties(${library_name} PROPERTIES LINK_FLAGS ${link_flags}) endif() - -# --- installation --------- - -#install (TARGETS ${library_name} DESTINATION ${destination_lib} COMPONENT Libraries) -#install (FILES ${include_files} DESTINATION ${destination_include} COMPONENT Headers) diff --git a/Tests/UnitTests/Core/CMakeLists.txt b/Tests/UnitTests/Core/CMakeLists.txt index 824b1886d7e..070f4f29d48 100644 --- a/Tests/UnitTests/Core/CMakeLists.txt +++ b/Tests/UnitTests/Core/CMakeLists.txt @@ -3,14 +3,6 @@ ############################################################################ set(test UnitTestCore) -if(POLICY CMP0020) - cmake_policy(SET CMP0020 NEW) -endif() - -if(POLICY CMP0043) - cmake_policy(SET CMP0043 NEW) -endif() - include_directories(${CMAKE_SOURCE_DIR}/Tests/UnitTests/utilities) file(GLOB source_files "*/*.cpp" "../utilities/TestAll.cpp") diff --git a/Tests/UnitTests/Fit/CMakeLists.txt b/Tests/UnitTests/Fit/CMakeLists.txt index 3f29e7cf080..2cd1c801d2a 100644 --- a/Tests/UnitTests/Fit/CMakeLists.txt +++ b/Tests/UnitTests/Fit/CMakeLists.txt @@ -4,14 +4,6 @@ set(test UnitTestFit) -if(POLICY CMP0020) - cmake_policy(SET CMP0020 NEW) -endif() - -if(POLICY CMP0043) - cmake_policy(SET CMP0043 NEW) -endif() - include_directories(${CMAKE_SOURCE_DIR}/Tests/UnitTests/utilities) file(GLOB source_files "*.cpp" "../utilities/TestAll.cpp") diff --git a/Tests/UnitTests/GUI/CMakeLists.txt b/Tests/UnitTests/GUI/CMakeLists.txt index ddf2adcc111..a40e9e5d68c 100644 --- a/Tests/UnitTests/GUI/CMakeLists.txt +++ b/Tests/UnitTests/GUI/CMakeLists.txt @@ -4,14 +4,6 @@ set(test UnitTestGUI) -if(POLICY CMP0020) - cmake_policy(SET CMP0020 NEW) -endif() - -if(POLICY CMP0043) - cmake_policy(SET CMP0043 NEW) -endif() - file(GLOB source_files "*.cpp") file(GLOB include_files "*.h") diff --git a/Tests/UnitTests/Numeric/CMakeLists.txt b/Tests/UnitTests/Numeric/CMakeLists.txt index 4aac2074b03..f3fc2bb9fd8 100644 --- a/Tests/UnitTests/Numeric/CMakeLists.txt +++ b/Tests/UnitTests/Numeric/CMakeLists.txt @@ -3,14 +3,6 @@ ############################################################################ set(test UnitTestNumeric) -if(POLICY CMP0020) - cmake_policy(SET CMP0020 NEW) -endif() - -if(POLICY CMP0043) - cmake_policy(SET CMP0043 NEW) -endif() - if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_LINKED_AS_SHARED_LIBRARY=1") endif() diff --git a/ThirdParty/GUI/qcustomplot/CMakeLists.txt b/ThirdParty/GUI/qcustomplot/CMakeLists.txt index 1d73689015f..21d5d4ac20e 100644 --- a/ThirdParty/GUI/qcustomplot/CMakeLists.txt +++ b/ThirdParty/GUI/qcustomplot/CMakeLists.txt @@ -1,12 +1,6 @@ ############################################################################ # CMakeLists.txt file for building qcustomplot static library ############################################################################ -if(POLICY CMP0020) - cmake_policy(SET CMP0020 NEW) -endif() -if(POLICY CMP0043) - cmake_policy(SET CMP0043 NEW) -endif() set(library_name qcustomplot) set(source_files qcustomplot.h qcustomplot.cpp) diff --git a/ThirdParty/GUI/qt-manhattan-style/CMakeLists.txt b/ThirdParty/GUI/qt-manhattan-style/CMakeLists.txt index 9ec5be50c29..24fdaa55cc4 100644 --- a/ThirdParty/GUI/qt-manhattan-style/CMakeLists.txt +++ b/ThirdParty/GUI/qt-manhattan-style/CMakeLists.txt @@ -1,16 +1,6 @@ ############################################################################ # CMakeLists.txt file for building libManhattanStyle ############################################################################ -if(POLICY CMP0020) - cmake_policy(SET CMP0020 NEW) -endif() -if(POLICY CMP0043) - cmake_policy(SET CMP0043 NEW) -endif() -if(POLICY CMP0071) - cmake_policy(SET CMP0071 NEW) -endif() - set(library_name ManhattanStyle) set(SRCS diff --git a/ThirdParty/common/gtest/CMakeLists.txt b/ThirdParty/common/gtest/CMakeLists.txt index b6b96d7e07b..3d7abaf296c 100644 --- a/ThirdParty/common/gtest/CMakeLists.txt +++ b/ThirdParty/common/gtest/CMakeLists.txt @@ -1,10 +1,6 @@ ############################################################################ # CMakeLists.txt file for building gtest library ############################################################################ -if(POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) -endif() - # instructs CMake to consider libgtest.so as our project library (inspite of the fact, that # it is not installed) and to provide @rpath instead of hardcoded links. if(APPLE) diff --git a/cmake/bornagain/modules/BornAgainPolicy.cmake b/cmake/bornagain/modules/BornAgainPolicy.cmake new file mode 100644 index 00000000000..15eb6dcece9 --- /dev/null +++ b/cmake/bornagain/modules/BornAgainPolicy.cmake @@ -0,0 +1,25 @@ +if(APPLE) +if(POLICY CMP0025) + cmake_policy(SET CMP0025 NEW) +endif() +endif() + +if(POLICY CMP0020) + cmake_policy(SET CMP0020 NEW) +endif() + +if(POLICY CMP0028) + cmake_policy(SET CMP0028 NEW) +endif() + +if(POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) +endif() + +if(POLICY CMP0043) + cmake_policy(SET CMP0043 NEW) +endif() + +if(POLICY CMP0071) + cmake_policy(SET CMP0071 NEW) +endif() -- GitLab