forked from p2pderivatives/cfd-js
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
115 lines (95 loc) · 3.11 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
cmake_minimum_required(VERSION 3.13)
# configure.ac: AC_INIT([cfd-js], [1.0]
set(PACKAGE_VERSION_p2pderivatives 0.0.4)
####################
# options
####################
include(./cmake/CfdCommonOption.cmake)
include(./cmake/CfdWallyOption.cmake)
option(CFD_SHARED "force shared build (ON or OFF. default:OFF)" OFF)
option(ENABLE_CAPI "enable c-api (ON or OFF. default:OFF)" OFF)
option(ENABLE_JSONAPI "enable json-api (ON or OFF. default:ON)" ON)
if(NOT APPLE)
set(ENABLE_SHARED ON CACHE BOOL "" FORCE)
endif()
set(GENERATE_WALLY ON CACHE BOOL "" FORCE)
set(EXCLUDE_WALLYCORE_LIB ON CACHE BOOL "" FORCE)
set(ENABLE_JS_WRAPPER OFF CACHE BOOL "" FORCE)
####################
# common setting
####################
include(./cmake/CfdCommonSetting.cmake)
include(./cmake/ConvertSrclistFunction.cmake)
####################
# test
####################
project(cfdjs_all_test CXX)
if(ENABLE_TESTS)
enable_testing()
endif() # ENABLE_TESTS
####################
# install check
####################
set(EXTERNAL_FILENAME external_project_local_setting.config)
set(EXTERNAL_LOCAL_FILENAME local_resource/${EXTERNAL_FILENAME})
if(EXISTS ${EXTERNAL_LOCAL_FILENAME})
transform_makefile_srclist(${EXTERNAL_LOCAL_FILENAME} "${CMAKE_CURRENT_BINARY_DIR}/${EXTERNAL_FILENAME}.cmake")
include(${CMAKE_CURRENT_BINARY_DIR}/${EXTERNAL_FILENAME}.cmake)
endif()
if(CFDJS_VERSION)
set(PACKAGE_VERSION ${CFDJS_VERSION})
else()
set(PACKAGE_VERSION ${PACKAGE_VERSION_p2pderivatives})
endif()
set(CFDJSAPI_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/wrap_js/dl_lib/cmake/cfdjs_api-config.cmake")
if(EXISTS ${CFDJSAPI_CONFIG_FILE})
set(CFDJS_API_INSTALLED TRUE)
else()
include(FindPackageHandleStandardArgs)
find_package(cfdjs_api CONFIG
HINTS "${CMAKE_CURRENT_SOURCE_DIR}/wrap_js/dl_lib" "${CMAKE_CURRENT_SOURCE_DIR}/wrap_js/dl_lib/cmake")
find_package_handle_standard_args(cfdjs_api CONFIG_MODE)
if((NOT cfdjs_api_FOUND) OR (NOT ${cfdjs_api_FOUND}))
set(CFDJS_API_INSTALLED FALSE)
else()
set(CFDJS_API_INSTALLED TRUE)
endif() # find_package
endif()
####################
# subdirectories
####################
if(NOT CFD_SINGLE_BUILD)
add_subdirectory(external)
endif() # CFD_SINGLE_BUILD
if(CFDJS_API_INSTALLED)
message(STATUS "[CFDJS_API] use installed library.")
else()
add_subdirectory(src)
endif() # CFDJS_API_INSTALLED
if(NOT ENABLE_EMSCRIPTEN)
add_subdirectory(addon)
endif()
if(NOT CFDJS_API_INSTALLED)
####################
# install & export
####################
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${prefix})
set(libdir ${exec_prefix}/lib)
set(includedir ${prefix}/include)
configure_file(pc/cfd-js.pc.in cfd-js.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cfd-js.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
####################
# uninstall
####################
if(NOT TARGET uninstall)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/pc/cmake_uninstall.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
endif() # CFDJS_API_INSTALLED