Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake update #342

Merged
merged 11 commits into from
Oct 1, 2024
12 changes: 12 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,16 @@ jobs:
uses: ./.github/actions/quick_cmake
with:
cmake-version: "3.28"
if: success() || failure()

- name: Check CMake 3.29
uses: ./.github/actions/quick_cmake
with:
cmake-version: "3.29"
if: success() || failure()

- name: Check CMake 3.30
uses: ./.github/actions/quick_cmake
with:
cmake-version: "3.30"
if: success() || failure()
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "googletest"]
path = ThirdParty/googletest
url = https://github.com/google/googletest.git
[submodule "ThirdParty/googletest"]
path = ThirdParty/googletest
url = https://github.com/google/googletest.git
37 changes: 25 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Copyright (c) 2019-2023,
# Copyright (c) 2019-2024,
# Lawrence Livermore National Security, LLC;
# See the top-level NOTICE for additional details. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
Expand All @@ -9,7 +9,7 @@
# most of the policies, the new version is better (hence the change). We don't use the
# 3.0...3.17 syntax because of a bug in an older MSVC's built-in and modified CMake 3.11
if(${CMAKE_VERSION} VERSION_GREATER 3.20)
cmake_minimum_required(VERSION 3.20...3.28)
cmake_minimum_required(VERSION 3.20...3.30)
else()
cmake_minimum_required(VERSION 3.0)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
Expand All @@ -23,7 +23,7 @@ endif()
project(
${UNITS_CMAKE_PROJECT_NAME}
LANGUAGES C CXX
VERSION 0.9.1
VERSION 0.9.2
)
include(CMakeDependentOption)
include(CTest)
Expand Down Expand Up @@ -87,10 +87,15 @@ set(UNITS_NAMESPACE
CACHE STRING "Top-level namespace name. Default is `units`."
)

cmake_dependent_option(
UNITS_INSTALL "Generate and install cmake package files" ON
"CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME;NOT UNITS_BINARY_ONLY_INSTALL" OFF
)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND NOT UNITS_BINARY_ONLY_INSTALL)
option(UNITS_INSTALL
"Generate and install cmake package files and shared library if built" ON
)
else()
option(UNITS_INSTALL
"Generate and install cmake package files and shared library if built" OFF
)
endif()

mark_as_advanced(UNITS_INSTALL)

Expand Down Expand Up @@ -200,15 +205,23 @@ add_subdirectory(units)

if(UNITS_BUILD_FUZZ_TARGETS)
add_subdirectory(FuzzTargets)
elseif(UNITS_ENABLE_TESTS)
elseif(UNITS_ENABLE_TESTS AND NOT CMAKE_VERSION VERSION_LESS 3.13)
include(updateGitSubmodules)
enable_testing()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/ThirdParty/googletest/CMakeLists.txt")
submod_update(ThirdParty/googletest)
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()
if(NOT UNITS_HEADER_ONLY)
add_subdirectory(webserver)
add_subdirectory(converter)
endif()

elseif(UNITS_ENABLE_TESTS)
message(WARNING "UNITS unit tests only supported under cmake 3.13 or greater")
endif()

if(NOT UNITS_HEADER_ONLY AND NOT UNITS_BUILD_FUZZ_TARGETS)
add_subdirectory(webserver)
add_subdirectory(converter)
endif()

if(UNITS_INSTALL)
Expand Down
Loading
Loading