-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
119 lines (93 loc) · 4.97 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
116
117
118
119
cmake_minimum_required(VERSION 3.1)
project(libvoxelbot)
include("${CMAKE_CURRENT_SOURCE_DIR}/bin2sh.cmake.txt")
bin2h(SOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/libvoxelbot/generated/units.data" HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR}/libvoxelbot/generated/units_data.h" VARIABLE_NAME "LIBVOXELBOT_DATA_UNITS")
bin2h(SOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/libvoxelbot/generated/upgrades.bin" HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR}/libvoxelbot/generated/upgrades_data.h" VARIABLE_NAME "LIBVOXELBOT_DATA_UPGRADES")
bin2h(SOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/libvoxelbot/generated/abilities.bin" HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR}/libvoxelbot/generated/abilities_data.h" VARIABLE_NAME "LIBVOXELBOT_DATA_ABILITIES")
# add_subdirectory("cereal")
add_subdirectory("s2client-api")
# PYTHON_EXECUTABLE
# Use bin as the directory for all executables.
# This will make protoc easy to find.
# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# set(PYTHON_EXECUTABLE "/Users/arong/anaconda3/bin/python")
# set(CMAKE_CONFIGURATION_TYPES, ${CMAKE_CONFIGURATION_TYPES} RelWithDebug)
# set(CMAKE_CXX_FLAGS_RELWITHDEBUG "-O2 -g -fPIC")
# More dependencies
# include_directories(SYSTEM "${PROJECT_BINARY_DIR}/s2client-api/generated")
# Doesn't seem to be required, so it is commented out for now (might be required on Windows or something)
# include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/s2client-api/contrib/SDL-mirror/include")
# include_directories("s2client-api/contrib/SDL-mirror/include")
set(LIBVOXELBOT_ENABLE_PYTHON 0)
function (create_executable project_name mainfile)
# TODO: The .h files don't seem to be necessary (think only .cpp files should be included here anyway)
add_executable(${project_name} ${mainfile})
# Sets the grouping in IDEs like visual studio (last parameter is the group name)
set_target_properties(${project_name} PROPERTIES FOLDER target)
if (MSVC)
# set_target_properties(${project_name} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libcmt;libconcrt")
endif ()
target_link_libraries(${project_name} sc2api sc2lib sc2utils libvoxelbot)
if (LIBVOXELBOT_ENABLE_PYTHON)
target_link_libraries(${project_name} pybind11::embed)
endif()
endfunction ()
# Note: trying to add SDL2-static as the extra_libs parameter here causes pybind11 modules to fail to link (for unknown reasons, maybe PIC related?)
set(libvoxelbot_sources
"libvoxelbot/buildorder/build_order.cpp"
"libvoxelbot/buildorder/build_state.cpp"
"libvoxelbot/buildorder/build_time_estimator.cpp"
"libvoxelbot/buildorder/optimizer.cpp"
"libvoxelbot/buildorder/tracker.cpp"
"libvoxelbot/combat/combat_environment.cpp"
"libvoxelbot/combat/combat_upgrades.cpp"
"libvoxelbot/combat/simulator.cpp"
"libvoxelbot/common/unit_lists.cpp"
"libvoxelbot/generated/abilities.cpp"
"libvoxelbot/utilities/influence.cpp"
"libvoxelbot/utilities/mappings.cpp"
"libvoxelbot/utilities/pathfinding.cpp"
"libvoxelbot/utilities/predicates.cpp"
"libvoxelbot/utilities/profiler.cpp"
"libvoxelbot/utilities/python_utils.cpp"
"libvoxelbot/utilities/renderer.cpp"
"libvoxelbot/utilities/unit_data_caching.cpp"
"libvoxelbot/caching/dependency_analyzer.cpp"
)
add_library(libvoxelbot ${libvoxelbot_sources})
# Sets the grouping in IDEs like visual studio (last parameter is the group name)
set_target_properties(libvoxelbot PROPERTIES FOLDER target)
target_link_libraries(libvoxelbot sc2api sc2lib sc2utils)
# Require C++14
set_property(TARGET libvoxelbot PROPERTY CXX_STANDARD 14)
set_property(TARGET libvoxelbot PROPERTY CXX_STANDARD_REQUIRED ON)
# target_compile_options(libvoxelbot PRIVATE -Wall)
# Enable pybind11 bindings
target_compile_definitions(libvoxelbot PUBLIC LIBVOXELBOT_ENABLE_PYTHON=${LIBVOXELBOT_ENABLE_PYTHON})
# target_link_libraries(libvoxelbot pybind11)
# Multithreaded builds
if (MSVC)
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
endif ()
target_include_directories(libvoxelbot
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/s2client-api/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/s2client-api/examples/common> # TODO: Remove?
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/s2client-api/contrib/SDL-mirror/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/cereal/include>
PRIVATE
src/generated
)
target_include_directories(libvoxelbot
SYSTEM
PUBLIC
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/s2client-api/generated>
)
create_executable(test_combat_simulator "libvoxelbot/combat/simulator.test.cpp")
create_executable(test_build_optimizer "libvoxelbot/buildorder/optimizer.test.cpp")
create_executable(cache_mappings "libvoxelbot/caching/caching.cpp")
create_executable(example_combat_simulator "examples/combat_simulator.cpp")
create_executable(example_combat_simulator2 "examples/combat_simulator2.cpp")
create_executable(example_build_optimizer "examples/build_optimizer.cpp")