Skip to content

Commit

Permalink
#350: Add deprecated_option CMake function that warns the user about …
Browse files Browse the repository at this point in the history
…deprecated options
  • Loading branch information
JacobDomagala committed Jun 19, 2024
1 parent 2258b37 commit 5a2fed4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
53 changes: 29 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.17)
project(checkpoint VERSION 1.4.0)
project(magistrate VERSION 1.4.0)

include(cmake/turn_on_warnings.cmake)

Expand All @@ -14,25 +14,32 @@ endif()
include (CTest)
enable_testing()

option(checkpoint_tests_enabled "Enable checkpoint tests" OFF)
option(checkpoint_mpi_enabled "Enable checkpoint tests with MPI" OFF)
option(checkpoint_examples_enabled "Enable checkpoint examples" OFF)
option(checkpoint_warnings_as_errors "Enable warnings to generate errors" OFF)
option(checkpoint_asan_enabled "Enable address sanitizer in Checkpoint" OFF)
option(
checkpoint_ubsan_enabled
"Enable undefined behavior sanitizer in Checkpoint" OFF
)
function(deprecated_option old_option new_option description default_value)
option(${new_option} "${description}" ${default_value})
if(DEFINED ${old_option})
message(DEPRECATION "Warning: ${old_option} is deprecated and will be removed in a future version. Use ${new_option} instead.")
set(${new_option} "${${old_option}}" CACHE BOOL "${description}" FORCE)
endif()
endfunction()

deprecated_option(checkpoint_tests_enabled magistrate_tests_enabled "Enable magistrate tests" OFF)
deprecated_option(checkpoint_mpi_enabled magistrate_mpi_enabled "Enable magistrate tests with MPI" OFF)
deprecated_option(checkpoint_examples_enabled magistrate_examples_enabled "Enable magistrate examples" OFF)
deprecated_option(checkpoint_warnings_as_errors magistrate_warnings_as_errors "Enable warnings to generate errors" OFF)
deprecated_option(checkpoint_asan_enabled magistrate_asan_enabled "Enable address sanitizer in magistrate" OFF)
deprecated_option(checkpoint_ubsan_enabled magistrate_ubsan_enabled "Enable undefined behavior sanitizer in magistrate" OFF)

option(CODE_COVERAGE "Enable coverage reporting" OFF)

if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
option(checkpoint_serialization_error_checking_enabled "Enable extensive serialization error checking" ON)
set(error_check ON)
else()
option(checkpoint_serialization_error_checking_enabled "Enable extensive serialization error checking" OFF)
set(error_check OFF)
endif()
deprecated_option(checkpoint_serialization_error_checking_enabled
magistrate_serialization_error_checking_enabled "Enable extensive serialization error checking" ${error_check})

if(checkpoint_serialization_error_checking_enabled)
if(magistrate_serialization_error_checking_enabled)
add_definitions(-DSERIALIZATION_ERROR_CHECKING)
message(STATUS "Building with serialization error checking enabled")
endif()
Expand All @@ -46,30 +53,28 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND NOT DEFINED CMAKE_CXX_
endif()

# MPI package
if(checkpoint_mpi_enabled)
if(magistrate_mpi_enabled)
include(cmake/load_mpi_package.cmake)
set(
CHECK_POINT_MPI_PROC 2 CACHE STRING
MAGISTRATE_MPI_PROC 2 CACHE STRING
"Set number of proc used by MPI for the tests. 2 is the default."
)
endif()

message (STATUS "Checkpoint build tests: ${checkpoint_tests_enabled}")
message (STATUS "Checkpoint build examples: ${checkpoint_examples_enabled}")
message (STATUS "Magistrate build tests: ${magistrate_tests_enabled}")
message (STATUS "Magistrate build examples: ${magistrate_examples_enabled}")

include(cmake/load_package.cmake)

option(
checkpoint_doxygen_enabled "Build doxygen documentation for checkpoint" OFF
)
deprecated_option(checkpoint_doxygen_enabled magistrate_doxygen_enabled "Build doxygen documentation for checkpoint" OFF)

# Doxygen library
if (${checkpoint_doxygen_enabled})
if (${magistrate_doxygen_enabled})
include(cmake/load_doxygen.cmake)
endif()

# Optionally enable address sanitizer library in build
if (checkpoint_asan_enabled)
if (magistrate_asan_enabled)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
Expand All @@ -84,7 +89,7 @@ if (checkpoint_asan_enabled)
endif()
endif()

if (checkpoint_ubsan_enabled)
if (magistrate_ubsan_enabled)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
Expand Down Expand Up @@ -147,7 +152,7 @@ else()
endif()

# If checkpoint build tests require the GTest package
if (${checkpoint_tests_enabled})
if (${magistrate_tests_enabled})
if(NOT hasParent)
find_package(GTest REQUIRED)
set(CHECKPOINT_HAS_GTEST TRUE)
Expand Down
1 change: 0 additions & 1 deletion ci/build_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ cmake -G "${CMAKE_GENERATOR:-Ninja}" \
-Dcheckpoint_asan_enabled="${CHECKPOINT_ASAN_ENABLED:-0}" \
-Dcheckpoint_ubsan_enabled="${CHECKPOINT_UBSAN_ENABLED:-0}" \
-Dcheckpoint_serialization_error_checking_enabled="${CHECKPOINT_SERIALIZATION_ERROR_CHECKING_ENABLED:-$is_debug}" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DCMAKE_BUILD_TYPE="${cmake_build_type}" \
-DCMAKE_CXX_COMPILER="${CXX:-c++}" \
-DCMAKE_C_COMPILER="${CC:-cc}" \
Expand Down
8 changes: 4 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(PROJECT_TEST_UNIT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/unit)
set(PROJECT_TEST_MPI_UNIT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/unit/tests_mpi)

if(checkpoint_mpi_enabled)
if(magistrate_mpi_enabled)
message(STATUS "Building unit tests with MPI")
file(
GLOB
Expand Down Expand Up @@ -38,7 +38,7 @@ macro(checkpoint_link_target target has_mpi)
endif()
endmacro()

if (checkpoint_tests_enabled)
if (magistrate_tests_enabled)
if (NOT CHECKPOINT_HAS_GTEST)
message(
STATUS
Expand All @@ -61,7 +61,7 @@ if (checkpoint_tests_enabled)
#System's threading library info (eg pthread)
find_package(Threads REQUIRED)

if(checkpoint_mpi_enabled)
if(magistrate_mpi_enabled)
set(
TEST_HEADER_FILES ${TEST_HEADER_FILES}
${PROJECT_TEST_MPI_UNIT_DIR}/mpi-init.h
Expand Down Expand Up @@ -120,7 +120,7 @@ if (checkpoint_tests_enabled)

set(
CHECKPOINT_TEST_PARAM_MPI ${MPI_NUMPROC_FLAG}
${CHECK_POINT_MPI_PROC} "${CMAKE_CURRENT_BINARY_DIR}/${TEST}"
${MAGISTRATE_MPI_PROC} "${CMAKE_CURRENT_BINARY_DIR}/${TEST}"
)
add_test(
NAME checkpoint:${TEST}
Expand Down

0 comments on commit 5a2fed4

Please sign in to comment.