Skip to content

Commit dc0ba16

Browse files
committed
Follow GNU install conventions
- allow customization of install locations by GNUInstallDirs module - enable project installation on CI testing
1 parent 0c50e78 commit dc0ba16

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

Diff for: .github/workflows/CI.yml

+18-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ jobs:
5959
brew link gcc@${GCC_V}
6060
6161
- name: Configure with CMake
62-
run: cmake -Wdev -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAXIMUM_RANK=4 -S . -B build
62+
run: >-
63+
cmake -Wdev
64+
-DCMAKE_BUILD_TYPE=Release
65+
-DCMAKE_MAXIMUM_RANK=4
66+
-DCMAKE_INSTALL_PREFIX=$PWD/_dist
67+
-S . -B build
6368
6469
- name: Build and compile
6570
run: cmake --build build
@@ -72,6 +77,9 @@ jobs:
7277
run: ctest --parallel --output-on-failure
7378
working-directory: build
7479

80+
- name: Install project
81+
run: cmake --install build
82+
7583
- name: Test in-tree builds
7684
if: contains( matrix.gcc_v, '10') # Only test one compiler on each platform
7785
run: |
@@ -129,7 +137,12 @@ jobs:
129137
run: pip install --upgrade fypp
130138

131139
- name: Configure with CMake
132-
run: cmake -Wdev -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAXIMUM_RANK=4 -S . -B build
140+
run: >-
141+
cmake -Wdev
142+
-DCMAKE_BUILD_TYPE=Release
143+
-DCMAKE_MAXIMUM_RANK=4
144+
-DCMAKE_INSTALL_PREFIX=$PWD/_dist
145+
-S . -B build
133146
134147
- name: Build and compile
135148
run: cmake --build build
@@ -141,3 +154,6 @@ jobs:
141154
- name: test
142155
run: ctest --parallel --output-on-failure
143156
working-directory: build
157+
158+
- name: Install project
159+
run: cmake --install build

Diff for: .github/workflows/ci_windows.yml

+4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ jobs:
9999
-DCMAKE_BUILD_TYPE=Debug
100100
-DCMAKE_Fortran_FLAGS_DEBUG="-Wall -Wextra -Wimplicit-interface -fPIC -g -fcheck=all -fbacktrace"
101101
-DCMAKE_MAXIMUM_RANK=4
102+
-DCMAKE_INSTALL_PREFIX=$PWD/_dist
102103
env:
103104
FC: gfortran
104105
CC: gcc
@@ -120,3 +121,6 @@ jobs:
120121
with:
121122
name: WindowsCMakeTestlog
122123
path: build/Testing/Temporary/LastTest.log
124+
125+
- name: Install project
126+
run: cmake --install build

Diff for: CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.14.0)
22
project(stdlib Fortran)
33
enable_testing()
44

5+
# Follow GNU conventions for installation directories
6+
include(GNUInstallDirs)
7+
58
include(${PROJECT_SOURCE_DIR}/cmake/stdlib.cmake)
69

710
# --- compiler options
@@ -55,5 +58,5 @@ add_subdirectory(src)
5558

5659
install(EXPORT fortran_stdlib-targets
5760
NAMESPACE fortran_stdlib::
58-
DESTINATION "lib/cmake/fortran_stdlib"
61+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/fortran_stdlib"
5962
)

Diff for: src/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ add_subdirectory(tests)
6464

6565
install(TARGETS fortran_stdlib
6666
EXPORT fortran_stdlib-targets
67-
RUNTIME DESTINATION bin
68-
ARCHIVE DESTINATION lib
69-
LIBRARY DESTINATION lib
67+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
68+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
69+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
7070
)
71-
install(DIRECTORY ${LIB_MOD_DIR} DESTINATION include)
71+
install(DIRECTORY ${LIB_MOD_DIR} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

0 commit comments

Comments
 (0)