-
Notifications
You must be signed in to change notification settings - Fork 22
/
GeodeSupport.cmake
153 lines (132 loc) · 3.58 KB
/
GeodeSupport.cmake
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
include(CheckCXXCompilerFlag)
function(add_python_module _name)
add_library(
${_name} MODULE ${ARGN}
)
target_include_directories(
${_name}
PUBLIC
${PYTHON_INCLUDE_DIRS}
${NUMPY_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}
)
target_link_libraries(
${_name}
PUBLIC
${PYTHON_LIBRARIES}
)
set_target_properties(
${_name}
PROPERTIES
PREFIX ""
)
endfunction()
set(GEODE_MODULES)
macro(INSTALL_GEODE_HEADERS _name)
install(FILES ${ARGN} DESTINATION include/geode/${_name}/)
endmacro(INSTALL_GEODE_HEADERS)
macro(ADD_GEODE_MODULE _name)
option(BUILD_GEODE_${_name} "Build the ${_name} module" TRUE)
if (BUILD_GEODE_${_name})
message(STATUS "Building ${_name} module.")
# Handle the NO_MODULE argument
# If it exists in the source list, remove it and don't add module.cpp
# If it doesn't, do nothing and add module.cpp
set(_srcs ${ARGN})
list(FIND _srcs NO_MODULE _no_module)
if (_no_module EQUAL -1)
list(APPEND _srcs module.cpp)
else()
list(REMOVE_AT _srcs ${_no_module})
endif()
add_library(
${_name} OBJECT ${_srcs}
)
set(GEODE_MODULE_OBJECTS ${GEODE_MODULE_OBJECTS} $<TARGET_OBJECTS:${_name}> PARENT_SCOPE)
set_property(
TARGET ${_name}
PROPERTY CXX_STANDARD 11
)
target_compile_definitions(
${_name}
PRIVATE
BUILDING_geode
)
target_include_directories(
${_name}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../../
${CMAKE_CURRENT_BINARY_DIR}/../../
)
if (GMP_FOUND)
target_include_directories(
${_name}
PUBLIC
${GMP_INCLUDE}
)
endif()
target_compile_options(
${_name}
PUBLIC
-march=native
-mtune=native
-O3
-funroll-loops
-Wall
-Winit-self
-Woverloaded-virtual
-Wsign-compare
-fno-strict-aliasing
# -Werror
-Wno-unused-function
-Wno-array-bounds
-Wno-unknown-pragmas
-Wno-deprecated
-Wno-format-security
-Wno-attributes
-Wno-unused-variable
-Wno-ignored-attributes
-Wno-unused-result
-fPIC
)
CHECK_CXX_COMPILER_FLAG(-Wno-undefined-var-template COMPILER_CHECKS_UNDEFINED_VAR_TEMPLATE)
if (COMPILER_CHECKS_UNDEFINED_VAR_TEMPLATE)
target_compile_options(
${_name}
PUBLIC
-Wno-undefined-var-template
)
endif()
CHECK_CXX_COMPILER_FLAG(-Wno-misleading-indentation COMPILER_CHECKS_MISLEADING_INDENTATION)
if (COMPILER_CHECKS_MISLEADING_INDENTATION)
target_compile_options(
${_name}
PUBLIC
-Wno-misleading-indentation
)
endif()
if (GEODE_PYTHON)
target_include_directories(
${_name}
PUBLIC
${PYTHON_INCLUDE_DIRS}
${NUMPY_INCLUDE_DIRS}
)
file(GLOB _python_bits *.py)
set(_pytargets "")
foreach(_python_bit ${_python_bits})
get_filename_component(_pyfile ${_python_bit} NAME)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${_pyfile}" "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${_pyfile}"
COMMENT "Copying ${_pyfile} to build tree"
)
list(APPEND _pytargets "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}")
endforeach()
add_custom_target(${_name}-python
ALL DEPENDS ${_pytargets}
)
endif()
endif()
endmacro(ADD_GEODE_MODULE)