From 8b483d8b1179a8361b16b18291d93b5fe45b03cc Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Sun, 3 Dec 2023 15:15:53 +0800 Subject: [PATCH 1/2] Remove unused options Removing these options should be quite safe and CMake also warns about unused but set cache variables from the commandline. --- CMakeLists.txt | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c56d9063..88dd09e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,23 +28,6 @@ option( ${_CORROSION_TOP_LEVEL} ) -set( - CORROSION_GENERATOR_EXECUTABLE CACHE STRING - "Use prebuilt, non-bootstrapped corrosion-generator") -mark_as_advanced(CORROSION_GENERATOR_EXECUTABLE) - -option( - CORROSION_INSTALL_EXECUTABLE - "Controls whether corrosion-generator is installed with the package" - ${CORROSION_INSTALL_EXECUTABLE_DEFAULT} -) -mark_as_advanced(CORROSION_INSTALL_EXECUTABLE) - -if (CORROSION_GENERATOR_EXECUTABLE OR CORROSION_INSTALL_EXECUTABLE) - message(FATAL_ERROR "The Cache variables CORROSION_GENERATOR_EXECUTABLE CORROSION_INSTALL_EXECUTABLE" - " were removed.") -endif() - if (_CORROSION_TOP_LEVEL) # We need to enable a language for corrosions test to work. # For projects using corrosion this is not needed From a70a0dda297dd6b21ada58654490cccd55dff88a Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Sun, 3 Dec 2023 15:24:20 +0800 Subject: [PATCH 2/2] Use PROJECT_IS_TOP_LEVEL The variable was introduced in CMake 3.21, so we can use it now. --- CMakeLists.txt | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88dd09e9..90e2bd54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,25 +10,15 @@ project(Corrosion HOMEPAGE_URL "https://corrosion-rs.github.io/corrosion/" ) -# Default behavior: -# - If the project is being used as a subdirectory, then don't build tests and -# don't enable any languages. -# - If this is a top level project, then build tests and enable the C++ compiler -if (NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - set(_CORROSION_TOP_LEVEL OFF) -else() - set(_CORROSION_TOP_LEVEL ON) -endif() - # ==== Corrosion Configuration ==== option( CORROSION_BUILD_TESTS "Build Corrosion test project" - ${_CORROSION_TOP_LEVEL} + ${PROJECT_IS_TOP_LEVEL} ) -if (_CORROSION_TOP_LEVEL) +if (PROJECT_IS_TOP_LEVEL) # We need to enable a language for corrosions test to work. # For projects using corrosion this is not needed enable_language(C) @@ -49,7 +39,7 @@ if (CORROSION_BUILD_TESTS) endif() # If Corrosion is a subdirectory, do not enable its install code -if (NOT _CORROSION_TOP_LEVEL) +if (NOT PROJECT_IS_TOP_LEVEL) return() endif()