Skip to content

Commit

Permalink
cmake < 3.21 top_level
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed May 9, 2024
1 parent 1b0c950 commit 5dc9a1e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env:
HOMEBREW_NO_INSTALL_CLEANUP: 1
CTEST_NO_TESTS_ACTION: error
CMAKE_BUILD_PARALLEL_LEVEL: 4
CTEST_PARALLEL_LEVEL: 4
CTEST_PARALLEL_LEVEL: 0

on:
push:
Expand All @@ -28,13 +28,14 @@ jobs:

env:
FC: gfortran-13
CMAKE_INSTALL_PREFIX: ~/libs

steps:

- uses: actions/checkout@v4

- name: Configure
run: cmake --preset default -DBUILD_SHARED_LIBS:BOOL=${{ matrix.shared }} --install-prefix=${{ runner.temp }}
run: cmake --preset default -DBUILD_SHARED_LIBS:BOOL=${{ matrix.shared }}

- name: Build
run: cmake --build --preset default
Expand Down
9 changes: 8 additions & 1 deletion cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ include(GNUInstallDirs)

message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION} CMake ${CMAKE_VERSION} Toolchain ${CMAKE_TOOLCHAIN_FILE}")

option(${PROJECT_NAME}_BUILD_TESTING "Build tests" ${PROJECT_IS_TOP_LEVEL})
if(CMAKE_VERSION VERSION_LESS 3.21)
get_property(not_top DIRECTORY PROPERTY PARENT_DIRECTORY)
if(NOT not_top)
set(${PROJECT_NAME}_IS_TOP_LEVEL true)
endif()
endif()

option(${PROJECT_NAME}_BUILD_TESTING "Build tests" ${${PROJECT_NAME}_IS_TOP_LEVEL})

# Necessary for shared library with Visual Studio / Windows oneAPI
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS true)

0 comments on commit 5dc9a1e

Please sign in to comment.