Skip to content

Commit

Permalink
Cmake update (#342)
Browse files Browse the repository at this point in the history
* move addGoogleTest

add some more cmake code

update supported versions of CMAKE and some ThirdParty Dependencies

* update googletest

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update cmake

* only support google test for cmake 3.13 and higher

* update pipeline and fuzz build

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
phlptp and pre-commit-ci[bot] authored Oct 1, 2024
1 parent 0e7f8ea commit fb20ef8
Show file tree
Hide file tree
Showing 12 changed files with 322 additions and 142 deletions.
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

0 comments on commit fb20ef8

Please sign in to comment.