-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
executable file
·115 lines (91 loc) · 3.74 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
################################
# GLOBAL CONFIGURATION VARIABLES
################################
cmake_minimum_required (VERSION 3.7.2)
set (GMlib_VERSION_MAJOR 3)
set (GMlib_VERSION_MINOR 30)
project (GMlib VERSION ${GMlib_VERSION_MAJOR}.${GMlib_VERSION_MINOR} LANGUAGES C)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if (WIN32)
set(CMAKE_INSTALL_PREFIX "$ENV{HOMEPATH}/local" CACHE PATH "..." FORCE)
else ()
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/local" CACHE PATH "..." FORCE)
endif()
endif ()
#####################################################
# CUSTOM COMMAND TO CREATE INTERMEDIARY HEADER FILES
# FROM OPENCL SOURCES BEFORE COMPILING THE EXECUTABLE
#####################################################
macro(compile_cl basename)
add_custom_command (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${basename}.h
COMMAND cl2h ${CMAKE_CURRENT_SOURCE_DIR}/${basename}.cl ${CMAKE_CURRENT_BINARY_DIR}/${basename}.h ${basename}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${basename}.cl )
endmacro(compile_cl)
#######################################
# SET FILES AND DIRECTORIES TO BE BUILT
#######################################
find_package(OpenCL)
if (OpenCL_FOUND)
include_directories (${OpenCL_INCLUDE_DIRS})
else()
message ("OpenCL could not be found, please set it with:")
message ("cmake -DOpenCL_LIBRARIES=PATH_TO_OPENCL_LIB/libOpenCL.so -DOpenCL_INCLUDE_DIRS=PATH_TO_OPENCL_INC/include")
message (FATAL_ERROR "OpenCL libary could not be found.")
endif()
include_directories (${PROJECT_SOURCE_DIR}/sources)
find_package(libMeshb 7.5)
if(libMeshb_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWITH_LIBMESHB")
include_directories (${libMeshb_INCLUDE_DIRS})
include_directories (${PROJECT_SOURCE_DIR}/examples)
add_subdirectory (utilities)
add_subdirectory (examples/BallQuality)
add_subdirectory (examples/HeatCellCentered)
add_subdirectory (examples/MeshQuality)
add_subdirectory (examples/NodeSmoother)
add_subdirectory (examples/TestFeatures)
message (STATUS "LibMeshb include directory: " ${libMeshb_INCLUDE_DIRS})
else()
message (WARNING "
libMeshb 7.5 could not be found (or you may have an older version installed).
Consequently, examples and utilities will not be built.
You can download it from GitHub at https://github.com/LoicMarechal/libMeshb")
endif()
add_subdirectory (sources)
install (FILES LICENSE.txt copyright.txt DESTINATION share/GMlib)
install (DIRECTORY sample_meshes DESTINATION share/GMlib)
######################################
# SET PACKAGE AND DEPLOYMENT VARIABLES
######################################
if (CPACK)
include (InstallRequiredSystemLibraries)
set (CPACK_GENERATOR TXZ)
set (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/copyright.txt)
set (CPACK_PACKAGE_VERSION_MAJOR ${GMlib_VERSION_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${GMlib_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}/GMlib-target.cmake)
find_package(OpenCL)
set(GMlib_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include)
set(GMlib_LIBRARIES GM.3 ${OpenCL_LIBRARIES})
set(GMlib_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})