-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
68 lines (53 loc) · 2.44 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
cmake_minimum_required(VERSION 3.18)
project(CubeCobraRecommenderGenerators VERSION "0.0.1")
include (CheckCCompilerFlag)
include (CheckCXXCompilerFlag)
macro (ADD_FLAG_IF_AVAIL TARGET_NAME ACCESS_MODIFIER FLAG)
if (NOT "${FLAG}" STREQUAL "")
# create a variable for checking the flag if supported, e.g.:
# -fp-model=precise --> cxx_fp_model_precise
string (REGEX REPLACE "^-" "cxx_" FLAG_NAME "${FLAG}")
string (REPLACE "-" "_" FLAG_NAME "${FLAG_NAME}")
string (REPLACE " " "_" FLAG_NAME "${FLAG_NAME}")
string (REPLACE "=" "_" FLAG_NAME "${FLAG_NAME}")
# runs check to see flag is supported by compiler
check_cxx_compiler_flag ("${FLAG}" ${FLAG_NAME})
if (${FLAG_NAME})
target_compile_options (${TARGET_NAME} ${ACCESS_MODIFIER} $<$<COMPILE_LANGUAGE:CXX>:${FLAG}>)
endif ()
endif ()
endmacro ()
if(SKBUILD)
set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}")
set(Python_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}")
set(Python_LBIRARY "${PYTHON_LIBRARY}")
set(DUMMY "${PYTHON_VERSION_STRING}") # Not needed, silences a warning
endif()
set(Python_FIND_IMPLEMENTATIONS CPython PyPy)
find_package(Python REQUIRED COMPONENTS Interpreter Development)
execute_process(
COMMAND
"${Python_EXECUTABLE}" -c
"import pybind11; print(pybind11.get_cmake_dir())"
OUTPUT_VARIABLE _tmp_dir
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT
)
message("${_tmp_dir}")
list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
find_package(pybind11 CONFIG REQUIRED)
add_subdirectory(extern/concurrentqueue)
# pybind11_add_module(generator MODULE cpp/generator.cpp)
pybind11_add_module(draftbot_generator MODULE cpp/draftbot_generator.cpp)
target_compile_definitions(draftbot_generator PRIVATE VERSION_INFO=${PROJECT_VERSION})
target_include_directories(draftbot_generator PRIVATE extern/pcg-cpp/include)
target_link_libraries(draftbot_generator PRIVATE concurrentqueue)
target_compile_features(draftbot_generator PRIVATE cxx_std_17)
add_flag_if_avail (draftbot_generator PRIVATE -Wall)
add_flag_if_avail (draftbot_generator PRIVATE -Wextra)
add_flag_if_avail (draftbot_generator PRIVATE /W4)
add_flag_if_avail (draftbot_generator PRIVATE -march=native)
add_flag_if_avail (draftbot_generator PRIVATE -ffast-math)
add_flag_if_avail (draftbot_generator PRIVATE /arch:AVX2)
add_flag_if_avail (draftbot_generator PRIVATE -fdiagnostics-color)
add_flag_if_avail (draftbot_generator PRIVATE -fcolor-diagnostics)
install(TARGETS draftbot_generator DESTINATION .)