Skip to content

Commit ef48ac2

Browse files
Include CMake Config in CMake installation process (#14)
* Add CMake configuration file for installation * This aids in dependency resolution for other projects, like hohqmesh * Change from snake case format * CMake error messages from HOHQMesh suggest it's looking for ftobjectlibrary-config.cmake * Change to "set" to set build variables * set_and_check is unknown to CMake when installing HOHQMesh via spack * Update FFLAGS and change to camel case for config * FFLAGS default is now set to match the default in the Makefile make system (Per @sloede suggestion) * Change CMake config file naming format to camel case (canonical style of CMAKE, and requested by @sloede). * Add CI workflow for CMake build test * Set FC to compiler from build matrix Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Add CMake build/ directory to .gitignore * Move fortran compiler environment spec to env attribute We believe this can resolve issues with how environment variables are passed to Windows environments when cmake is called. Co-authored-by: Michael Schlottke-Lakemper <[email protected]> * Add Fortran compiler as cache variable * Testing to see if this patches the issue with Windows systems builds * Apply patch similar for CMake build tests * This commit matches @sloede's commit at 23738bc Co-authored-by: Joe Schoonover <[email protected]> Co-authored-by: Michael Schlottke-Lakemper <[email protected]>
1 parent bf5f2ce commit ef48ac2

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

.github/workflows/ci.yml

+10
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,26 @@ jobs:
2626
include:
2727
- os: ubuntu-latest
2828
compiler: gfortran-10
29+
cmake_generator: Unix Makefiles
2930
- os: macos-latest
3031
compiler: gfortran-10
32+
cmake_generator: Unix Makefiles
3133
- os: windows-latest
3234
compiler: gfortran
35+
cmake_generator: MinGW Makefiles
3336
steps:
3437
- name: Checkout repository
3538
uses: actions/checkout@v2
3639
# - name: Add msbuild to PATH
3740
# if: ${{ matrix.os == 'windows-latest' }}
3841
# uses: microsoft/[email protected]
42+
- name: Verify CMake build
43+
run: |
44+
mkdir build && cd build
45+
cmake -G "${{ matrix.cmake_generator }}" ../
46+
make
47+
env:
48+
FC: ${{ matrix.compiler }}
3949
- name: Verify regular build
4050
run: |
4151
cd makeLibrary

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Docs/FTObjectLibrary.toc
2828
*.mod
2929
runSuite
3030
libFTObjectLibrary.a
31+
build/
3132

3233
# auto-built documentation
3334
public/

CMakeLists.txt

+9-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2)
33
# You can override the compiler with cmake -DFTOBJ_COMPILER=
44
#set(FTOBJ_AR "/usr/bin/gcc-ar" CACHE STRING "Static archive command")
55
#set(FTOBJ_RANLIB "/usr/bin/gcc-ranlib" CACHE STRING "ranlib used to create Static archive")
6-
SET(FC "/usr/bin/gfortran" CACHE STRING "Fortran Compiler")
7-
SET(FFLAGS "-cpp" CACHE STRING "Fortran compiler flags")
6+
INCLUDE(CMakePackageConfigHelpers)
7+
SET(FFLAGS "-cpp -O -std=f2008 -pedantic -Werror -fimplicit-none -Wall -Wextra -Wcharacter-truncation -Wimplicit-interface -Wimplicit-procedure -Wno-compare-reals -Wno-unused-dummy-argument -Wno-intrinsic-shadow -Wno-implicit-interface -Wno-implicit-procedure" CACHE STRING "Fortran compiler flags")
88

99
MESSAGE("-- FTOBJ ------------- cmake START -------------------")
10-
MESSAGE("-- FC: ${FC}")
1110
MESSAGE("-- FFLAGS: ${FFLAGS}")
1211
MESSAGE("-- CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
1312
MESSAGE("-- FTOBJ ----------------------------------------------")
@@ -26,4 +25,11 @@ ENDIF(NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90)
2625

2726
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Source)
2827

28+
configure_package_config_file(FTObjectLibraryConfig.cmake.in
29+
${CMAKE_CURRENT_BINARY_DIR}/FTObjectLibraryConfig.cmake
30+
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}
31+
PATH_VARS CMAKE_INSTALL_PREFIX)
32+
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/FTObjectLibraryConfig.cmake
33+
DESTINATION ${CMAKE_INSTALL_PREFIX})
34+
2935
message("-- FTOBJ ------------- cmake DONE --------------------")

FTObjectLibraryConfig.cmake.in

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
set(FTOBJECTLIBRARY_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include")
3+
set(FTOBJECTLIBRARY_LIBRARY "@CMAKE_INSTALL_PREFIX@/lib/libftobject.a")

0 commit comments

Comments
 (0)