-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
120 lines (96 loc) · 3.88 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
################################
# GLOBAL CONFIGURATION VARIABLES
################################
cmake_minimum_required (VERSION 3.7.2)
set (libMeshb_VERSION_MAJOR 7)
set (libMeshb_VERSION_MINOR 80)
project(libMeshb VERSION ${libMeshb_VERSION_MAJOR}.${libMeshb_VERSION_MINOR} LANGUAGES C)
option(WITH_GMF_AIO "Use Unix low-level and asynchronous I/O for higher speed" OFF)
option(WITH_GMF_CPACK "Enable cpack target to generate a zip file containing binaries" OFF)
option(WITH_GMF_CTEST "Enable ctest ti run basic validation tests" OFF)
include (CheckLanguage)
check_language (Fortran)
if(CMAKE_Fortran_COMPILER)
enable_language(Fortran)
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/modules)
endif()
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()
if (CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
set (math_LIBRARIES "m")
endif ()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if (WIN32)
set(CMAKE_INSTALL_PREFIX "$ENV{HOMEPATH}/cmakebuilds" CACHE PATH "..." FORCE)
else ()
if (DEFINED ENV{OSTYPE} AND DEFINED ENV{MACHTYPE})
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/cmakebuilds/$ENV{OSTYPE}-$ENV{MACHTYPE}" CACHE PATH "..." FORCE)
else ()
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/cmakebuilds" CACHE PATH "..." FORCE)
endif ()
endif()
endif ()
list (APPEND CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}")
if(WITH_GMF_AIO)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWITH_GMF_AIO")
IF(${CMAKE_SYSTEM_NAME} MATCHES Linux)
set(AIO_LIBRARIES rt)
endif()
endif()
#######################################
# SET FILES AND DIRECTORIES TO BE BUILT
#######################################
include_directories (${PROJECT_SOURCE_DIR}/sources)
include_directories (${PROJECT_SOURCE_DIR}/utilities)
add_subdirectory (sources)
add_subdirectory (examples)
add_subdirectory (utilities)
install (FILES LICENSE.txt copyright.txt DESTINATION share/libMeshb)
install (DIRECTORY sample_meshes DESTINATION share/libMeshb)
######################################
# SET PACKAGE AND DEPLOYMENT VARIABLES
######################################
if(WITH_GMF_CTEST)
enable_testing()
include_directories(${PROJECT_SOURCE_DIR}/testing)
add_subdirectory(testing)
endif()
if (WITH_GMF_CPACK)
include (InstallRequiredSystemLibraries)
set (CPACK_GENERATOR TXZ)
set (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/copyright.txt)
set (CPACK_PACKAGE_VERSION_MAJOR ${libMeshb_VERSION_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${libMeshb_VERSION_MINOR})
set (CPACK_COMPONENTS_ALL applications examples libraries headers)
include (CPack)
endif ()
##################################
# EXPORT CMAKE PACKAGE INFORMATION
##################################
include(CMakePackageConfigHelpers)
file(WRITE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
"include(\${CMAKE_CURRENT_LIST_DIR}/meshb-target.cmake)
include(\${CMAKE_CURRENT_LIST_DIR}/libMeshb-target.cmake)
set(libMeshb_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include)
set(libMeshb_LINK_DIRS ${CMAKE_INSTALL_PREFIX}/lib)
set(libMeshb_LIBRARIES Meshb.7 ${AIO_LIBRARIES})
set(libMeshb_Fortran_LIBRARIES Meshbf.7 ${AIO_LIBRARIES})
set(libMeshb_FOUND TRUE)
")
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
install(FILES
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION lib/cmake/${PROJECT_NAME})
##################################
# PRINT OPERATIONS TO BE CONDUCTED
##################################
message("-- Build mode : " ${CMAKE_BUILD_TYPE})
message("-- cpack target enabled : " ${WITH_GMF_CPACK})
message("-- ctest target enabled : " ${WITH_GMF_CTEST})
message("-- Asynchronous IO : " ${WITH_GMF_AIO})
message("-- Install directory : " ${CMAKE_INSTALL_PREFIX})