--- a/tools/corrosion/CMakeLists.txt Wed Sep 18 14:10:51 2024 +0200
+++ b/tools/corrosion/CMakeLists.txt Wed Nov 20 21:37:47 2024 +0100
@@ -1,64 +1,24 @@
-cmake_minimum_required(VERSION 3.15)
+cmake_minimum_required(VERSION 3.22)
project(Corrosion
# Official releases will be major.minor.patch. When the `tweak` field is
# set it indicates that we are on a commit, that is not a officially
# tagged release. Users don't need to care about this, it is mainly to
# clearly see in configure logs which version was used, without needing to
# rely on `git`, since Corrosion may be installed or otherwise packaged.
- VERSION 0.5.0
+ VERSION 0.99.99 # 1.0-pre-release
LANGUAGES NONE
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_DEV_MODE
- "Enables some additional features if you're developing Corrosion"
- ${_CORROSION_TOP_LEVEL}
-)
-
-option(
CORROSION_BUILD_TESTS
"Build Corrosion test project"
- ${_CORROSION_TOP_LEVEL}
+ ${PROJECT_IS_TOP_LEVEL}
)
-set(
- CORROSION_GENERATOR_EXECUTABLE CACHE STRING
- "Use prebuilt, non-bootstrapped corrosion-generator")
-mark_as_advanced(CORROSION_GENERATOR_EXECUTABLE)
-
-if (CORROSION_GENERATOR_EXECUTABLE)
- add_executable(Corrosion::Generator IMPORTED GLOBAL)
- set_property(
- TARGET Corrosion::Generator
- PROPERTY IMPORTED_LOCATION ${CORROSION_GENERATOR_EXECUTABLE})
- set(CORROSION_INSTALL_EXECUTABLE_DEFAULT OFF)
-elseif(CORROSION_NATIVE_TOOLING OR CMAKE_VERSION VERSION_LESS 3.19.0)
- set(CORROSION_INSTALL_EXECUTABLE_DEFAULT "ON")
-else()
- set(CORROSION_INSTALL_EXECUTABLE_DEFAULT OFF)
-endif()
-
-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_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)
@@ -69,8 +29,11 @@
#
# It is strongly encouraged to install Corrosion separately and use
# `find_package(Corrosion REQUIRED)` instead if that works with your workflow.
-list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
-include(Corrosion)
+option(CORROSION_INSTALL_ONLY "Only add rules for installing Corrosion itself." OFF)
+if (NOT CORROSION_INSTALL_ONLY)
+ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+ include(Corrosion)
+endif()
# Testing
if (CORROSION_BUILD_TESTS)
@@ -79,7 +42,7 @@
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()
@@ -87,18 +50,6 @@
include(GNUInstallDirs)
-if(CORROSION_INSTALL_EXECUTABLE)
- get_property(
- _CORROSION_GENERATOR_EXE
- TARGET Corrosion::Generator PROPERTY IMPORTED_LOCATION
- )
- install(PROGRAMS "${_CORROSION_GENERATOR_EXE}" DESTINATION "${CMAKE_INSTALL_FULL_LIBEXECDIR}")
-else()
- message(DEBUG "Not installing corrosion-generator since "
- "`CORROSION_INSTALL_EXECUTABLE` is set to ${CORROSION_INSTALL_EXECUTABLE}"
- )
-endif()
-
# Generate the Config file
include(CMakePackageConfigHelpers)
@@ -112,7 +63,7 @@
"${CMAKE_CURRENT_BINARY_DIR}/CorrosionConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY
- SameMinorVersion # TODO: Should be SameMajorVersion when 1.0 is released
+ SameMajorVersion
ARCH_INDEPENDENT
)