This repository was archived by the owner on Mar 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathMakefileBuildOptions.cmake
More file actions
85 lines (75 loc) · 3.5 KB
/
MakefileBuildOptions.cmake
File metadata and controls
85 lines (75 loc) · 3.5 KB
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
# =============================================================================
# Copyright (C) 2016-2021 Blue Brain Project
#
# See top-level LICENSE file for details.
# =============================================================================
# =============================================================================
# Common CXX and ISPC flags
# =============================================================================
# ISPC should compile with --pic by default
set(CMAKE_ISPC_FLAGS "${CMAKE_ISPC_FLAGS} --pic")
# =============================================================================
# NMODL CLI options : common and backend specific
# =============================================================================
# ~~~
# if user pass arguments then use those as common arguments
# note that inlining is done by default
# ~~~
set(NMODL_COMMON_ARGS "passes --inline")
if(NOT "${CORENRN_NMODL_FLAGS}" STREQUAL "")
set(NMODL_COMMON_ARGS "${NMODL_COMMON_ARGS} ${CORENRN_NMODL_FLAGS}")
endif()
set(NMODL_CPU_BACKEND_ARGS "host --c")
set(NMODL_ISPC_BACKEND_ARGS "host --ispc")
set(NMODL_ACC_BACKEND_ARGS "host --c acc --oacc")
# =============================================================================
# Extract Compile definitions : common to all backend
# =============================================================================
get_directory_property(COMPILE_DEFS COMPILE_DEFINITIONS)
if(COMPILE_DEFS)
set(CORENRN_COMMON_COMPILE_DEFS "")
foreach(flag ${COMPILE_DEFS})
set(CORENRN_COMMON_COMPILE_DEFS "${CORENRN_COMMON_COMPILE_DEFS} -D${flag}")
endforeach()
endif()
# =============================================================================
# link flags : common to all backend
# =============================================================================
# ~~~
# find_cuda uses FindThreads that adds below imported target we
# shouldn't add imported target to link line
# ~~~
list(REMOVE_ITEM CORENRN_LINK_LIBS "Threads::Threads")
# replicate CMake magic to transform system libs to -l<libname>
foreach(link_lib ${CORENRN_LINK_LIBS})
if(${link_lib} MATCHES "\-l.*")
string(APPEND CORENRN_COMMON_LDFLAGS " ${link_lib}")
continue()
endif()
get_filename_component(path ${link_lib} DIRECTORY)
if(NOT path)
string(APPEND CORENRN_COMMON_LDFLAGS " -l${link_lib}")
elseif("${path}" MATCHES "^(/lib|/lib64|/usr/lib|/usr/lib64)$")
get_filename_component(libname ${link_lib} NAME_WE)
string(REGEX REPLACE "^lib" "" libname ${libname})
string(APPEND CORENRN_COMMON_LDFLAGS " -l${libname}")
else()
string(APPEND CORENRN_COMMON_LDFLAGS " ${link_lib}")
endif()
endforeach()
# =============================================================================
# compile flags : common to all backend
# =============================================================================
# PGI compiler adds --c++14;-A option for C++14, remove ";"
string(REPLACE ";" " " CXX14_STD_FLAGS "${CMAKE_CXX14_STANDARD_COMPILE_OPTION}")
string(TOUPPER "${CMAKE_BUILD_TYPE}" _BUILD_TYPE)
set(CORENRN_CXX_FLAGS
"${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${_BUILD_TYPE}} ${CXX14_STD_FLAGS} ${NVHPC_ACC_COMP_FLAGS} ${NVHPC_CXX_INLINE_FLAGS}"
)
set(CORENRN_LD_FLAGS "${NVHPC_ACC_LINK_FLAGS}")
# =============================================================================
# nmodl/mod2c related options : TODO
# =============================================================================
# name of nmodl/mod2c binary
get_filename_component(nmodl_name ${CORENRN_MOD2CPP_BINARY} NAME)
set(nmodl_binary_name ${nmodl_name})