forked from Goddard-Fortran-Ecosystem/fArgParse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
78 lines (64 loc) · 2.51 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
cmake_minimum_required(VERSION 3.12)
project (FARGPARSE
VERSION 1.1.0
LANGUAGES Fortran)
# Most users of this software do not (should not?) have permissions to
# install in the cmake default of /usr/local (or equiv on other os's).
# Below, the default is changed to a directory within the build tree
# unless the user explicitly sets CMAKE_INSTALL_PREFIX in the cache.
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/installed" CACHE PATH "default install path" FORCE )
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
include(${CMAKE_Fortran_COMPILER_ID} RESULT_VARIABLE found)
if(NOT found)
message( FATAL_ERROR "Unrecognized Fortran compiler. Please use ifort, gfortran, NAG, PGI, or XL.")
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory (src)
if (examples)
add_subdirectory(Examples)
endif()
find_package (PFUNIT 4.0.1 QUIET)
if (PFUNIT_FOUND)
project (FARGPARSE_-TEST
VERSION ${FARGPARSE_VERSION}
LANGUAGES Fortran
)
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${GFTL_SOURCE_DIR}/cmake_utils")
include (${CMAKE_Fortran_COMPILER_ID} RESULT_VARIABLE found)
enable_testing()
if (NOT TARGET tests)
add_custom_target(tests COMMAND ${CMAKE_CTEST_COMMAND})
endif ()
add_subdirectory(tests)
endif ()
# find_package() support
include(CMakePackageConfigHelpers)
configure_package_config_file(FARGPARSEConfig.cmake.in FARGPARSEConfig.cmake
INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/FARGPARSEConfig.cmake
)
write_basic_package_version_file(FARGPARSEConfig-version.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY SameMajorVersion
)
set (top_dir FARGPARSE-${FARGPARSE_VERSION_MAJOR}.${FARGPARSE_VERSION_MINOR})
install (
FILES ${CMAKE_CURRENT_BINARY_DIR}/FARGPARSEConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/FARGPARSEConfig-version.cmake
DESTINATION "${top_dir}/cmake")
# The following is needed for external projects using *nix make when
# parent project builds fArgParse as a subproject.
set (FARGPARSE_TOP_DIR "${CMAKE_INSTALL_PREFIX}/${top_dir}" CACHE PATH "")
configure_file (FARGPARSE.mk.in ${CMAKE_CURRENT_BINARY_DIR}/FARGPARSE.mk @ONLY)
install (
FILES ${CMAKE_CURRENT_BINARY_DIR}/FARGPARSE.mk ${CMAKE_CURRENT_BINARY_DIR}/FARGPARSE.mk
DESTINATION "${top_dir}/include")
install(EXPORT FARGPARSE
FILE FARGPARSETargets.cmake
NAMESPACE FARGPARSE::
DESTINATION "${top_dir}/cmake"
)
export(EXPORT FARGPARSE
FILE "${CMAKE_CURRENT_BINARY_DIR}/FARGPARSETargets.cmake"
NAMESPACE FARGPARSE::
)