From 2d3be10d0f2459d51edeea54a44ea57112a9afec Mon Sep 17 00:00:00 2001 From: Luca Bertagna Date: Wed, 8 Apr 2026 10:40:28 -0600 Subject: [PATCH 1/3] Bump minimum cmake version to 3.18, remove legacy cmake code --- CMakeLists.txt | 6 ++---- cmake/EkatCreateUnitTest.cmake | 10 ++++------ cmake/EkatUtils.cmake | 9 ++------- cmake/tpls/EkatBuildCatch2.cmake | 13 +------------ cmake/tpls/EkatBuildSpdlog.cmake | 13 +------------ cmake/tpls/EkatBuildYamlCpp.cmake | 13 +------------ 6 files changed, 11 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96322637..e74d119b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,9 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.18) set (EKAT_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake CACHE INTERNAL "") # Do not ignore env vars in find_package() calls -if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0") - cmake_policy (SET CMP0074 NEW) -endif(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0") +cmake_policy (SET CMP0074 NEW) # Add our own cmake goodies to cmake module search path list(APPEND CMAKE_MODULE_PATH diff --git a/cmake/EkatCreateUnitTest.cmake b/cmake/EkatCreateUnitTest.cmake index 047adc2f..e69a9e24 100644 --- a/cmake/EkatCreateUnitTest.cmake +++ b/cmake/EkatCreateUnitTest.cmake @@ -57,19 +57,17 @@ function(EkatCreateUnitTestExec exec_name exec_srcs) # Create the executable and set its properties # #-------------------------------------------------# - # Set link directories (must be done BEFORE add_executable is called) - # NOTE: CMake 3.15 adds 'target_link_directories', which is superior (does not pollute other targets). - # We should switch to that as soon as we can assume CMAKE_VERSION >= 3.15. set(target_name ${exec_name}) - if (ecute_LIBS_DIRS) - link_directories("${ecute_LIBS_DIRS}") - endif() add_executable(${target_name} ${exec_srcs}) #---------------------------# # Set all target properties # #---------------------------# + if (ecute_LIBS_DIRS) + target_link_directories(${target_name} PUBLIC "${ecute_LIBS_DIRS}") + endif() + target_link_libraries (${exec_name} PUBLIC Catch2::Catch2) # Include dirs diff --git a/cmake/EkatUtils.cmake b/cmake/EkatUtils.cmake index 46c72351..8ef74a62 100644 --- a/cmake/EkatUtils.cmake +++ b/cmake/EkatUtils.cmake @@ -126,13 +126,8 @@ macro (EkatDisableAllWarning targetName) $<$:$<$:-w> $<$: -w>>) target_compile_options (${targetName} PRIVATE $<$:$<$:-w -fcompare-debug-second> $<$: -w>>) - if (${CMAKE_VERSION} VERSION_LESS "3.14.0") - target_compile_options (${targetName} PRIVATE - $<$:$<$:-w> $<$: -w>>) - else () - target_compile_options (${targetName} PRIVATE - $<$:$<$:-w> $<$: -w>>) - endif() + target_compile_options (${targetName} PRIVATE + $<$:$<$:-w> $<$: -w>>) endmacro (EkatDisableAllWarning) function(separate_cut_arguments prefix options oneValueArgs multiValueArgs return_varname) diff --git a/cmake/tpls/EkatBuildCatch2.cmake b/cmake/tpls/EkatBuildCatch2.cmake index 7c5cf8f6..6bf7e358 100644 --- a/cmake/tpls/EkatBuildCatch2.cmake +++ b/cmake/tpls/EkatBuildCatch2.cmake @@ -16,15 +16,4 @@ FetchContent_Declare(Catch2 BINARY_DIR ${EKAT_BINARY_DIR}/extern/Catch2 ) -# MakeAvailable is better, but we need CMake>=3.14... -if(CMAKE_VERSION VERSION_LESS "3.14") - # Legacy path for CMake 3.11 - 3.13 - FetchContent_GetProperties(Catch2) - if(NOT catch2_POPULATED) - FetchContent_Populate(Catch2) - add_subdirectory(${catch2_SOURCE_DIR} ${catch2_BINARY_DIR}) - endif() -else() - # Modern path for 3.14+ (Silences CMP0169 in 3.30+) - FetchContent_MakeAvailable(Catch2) -endif() +FetchContent_MakeAvailable(Catch2) diff --git a/cmake/tpls/EkatBuildSpdlog.cmake b/cmake/tpls/EkatBuildSpdlog.cmake index 33b08217..0acbed6d 100644 --- a/cmake/tpls/EkatBuildSpdlog.cmake +++ b/cmake/tpls/EkatBuildSpdlog.cmake @@ -15,18 +15,7 @@ FetchContent_Declare(spdlog BINARY_DIR ${EKAT_BINARY_DIR}/extern/spdlog ) -# MakeAvailable is better, but we need CMake>=3.14... -if(CMAKE_VERSION VERSION_LESS "3.14") - # Legacy path for CMake 3.11 - 3.13 - FetchContent_GetProperties(spdlog) - if(NOT spdlog_POPULATED) - FetchContent_Populate(spdlog) - add_subdirectory (${spdlog_SOURCE_DIR} ${spdlog_BINARY_DIR}) - endif() -else() - # Modern path for 3.14+ (Silences CMP0169 in 3.30+) - FetchContent_MakeAvailable(spdlog) -endif() +FetchContent_MakeAvailable(spdlog) if (EKAT_DISABLE_TPL_WARNINGS) include (EkatUtils) diff --git a/cmake/tpls/EkatBuildYamlCpp.cmake b/cmake/tpls/EkatBuildYamlCpp.cmake index eecf197a..3d02d5f3 100644 --- a/cmake/tpls/EkatBuildYamlCpp.cmake +++ b/cmake/tpls/EkatBuildYamlCpp.cmake @@ -14,18 +14,7 @@ FetchContent_Declare(yaml-cpp BINARY_DIR ${EKAT_BINARY_DIR}/extern/yaml-cpp ) -# MakeAvailable is better, but we need CMake>=3.14... -if(CMAKE_VERSION VERSION_LESS "3.14") - # Legacy path for CMake 3.11 - 3.13 - FetchContent_GetProperties(yaml-cpp) - if(NOT yaml-cpp_POPULATED) - FetchContent_Populate(yaml-cpp) - add_subdirectory (${yaml-cpp_SOURCE_DIR} ${yaml-cpp_BINARY_DIR}) - endif() -else() - # Modern path for 3.14+ (Silences CMP0169 in 3.30+) - FetchContent_MakeAvailable(yaml-cpp) -endif() +FetchContent_MakeAvailable(yaml-cpp) if (EKAT_DISABLE_TPL_WARNINGS) include (EkatUtils) From bf30ba140ee118a87adcf5457ff2a4c87eef5521 Mon Sep 17 00:00:00 2001 From: Luca Bertagna Date: Wed, 8 Apr 2026 10:40:55 -0600 Subject: [PATCH 2/3] Bump EKAT version to 2.0 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e74d119b..3a3939b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,9 +27,9 @@ endif() include(EkatUtils) IsDebugBuild(EKAT_IS_DEBUG_BUILD) -set (EKAT_VERSION_MAJOR 1) +set (EKAT_VERSION_MAJOR 2) set (EKAT_VERSION_MINOR 0) -set (EKAT_VERSION_PATCH 1) +set (EKAT_VERSION_PATCH 0) message(STATUS "EKAT version: ${EKAT_VERSION_MAJOR}.${EKAT_VERSION_MINOR}.${EKAT_VERSION_PATCH}") From 064b12821b6f85aa4ecf6314ba05c52007eefbf2 Mon Sep 17 00:00:00 2001 From: Luca Bertagna Date: Wed, 8 Apr 2026 11:52:58 -0600 Subject: [PATCH 3/3] Set target link dirs as a PRIVATE property on unit test execs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- cmake/EkatCreateUnitTest.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/EkatCreateUnitTest.cmake b/cmake/EkatCreateUnitTest.cmake index e69a9e24..96cfe558 100644 --- a/cmake/EkatCreateUnitTest.cmake +++ b/cmake/EkatCreateUnitTest.cmake @@ -65,7 +65,7 @@ function(EkatCreateUnitTestExec exec_name exec_srcs) #---------------------------# if (ecute_LIBS_DIRS) - target_link_directories(${target_name} PUBLIC "${ecute_LIBS_DIRS}") + target_link_directories(${target_name} PRIVATE "${ecute_LIBS_DIRS}") endif() target_link_libraries (${exec_name} PUBLIC Catch2::Catch2)