forked from davechurchill/commandcenter
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Rebase to new cpp-sc2 and rework build routine
- Fetch cpp-sc2 using CMake instead of manual manipulations with submodule. - Make changes necessary to compile with new cpp-sc2. - Refactor CMake build routine. - Update build instructions. Signed-off-by: Alexander Kurbatov <[email protected]>
- Loading branch information
1 parent
ebbfc7f
commit 01fbc12
Showing
6 changed files
with
77 additions
and
60 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
project(CommandCenter) | ||
|
||
include(FetchContent) | ||
|
||
# Specify output directories. | ||
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin") | ||
|
||
# Build with c++14 support, required by sc2api. | ||
set(CMAKE_CXX_STANDARD 14) | ||
|
||
# Disable building of examples in the sc2api submodule. | ||
set(BUILD_API_EXAMPLES OFF CACHE INTERNAL "" FORCE) | ||
if (MSVC) | ||
# Setup MSVC parallelized builds | ||
add_compile_options(/MP) | ||
|
||
# Use statically linked runtime | ||
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>) | ||
endif () | ||
|
||
# Disable building of tests in the sc2api submodule. | ||
set(BUILD_API_TESTS OFF CACHE INTERNAL "" FORCE) | ||
list(APPEND CMAKE_MODULE_PATH thirdparty/cmake) | ||
|
||
# Dont build sc2renderer in the sc2api submodule. | ||
set(BUILD_SC2_RENDERER OFF CACHE INTERNAL "" FORCE) | ||
# cpp-sc2 dependency | ||
include(cpp_sc2) | ||
|
||
add_subdirectory("cpp-sc2") | ||
add_subdirectory("src") | ||
add_subdirectory(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,56 +41,65 @@ By default when you run CommandCenter.exe, it will play as Random race vs. a Ran | |
|
||
If the bot crashes or does other nasty things, please bear with me while I make it more stable :) | ||
|
||
# Developer Install / Compile Instructions (Windows) | ||
# Developer Install / Compile Instructions | ||
## Windows | ||
* Download and install [Visual Studio 2017 or newer](https://www.visualstudio.com/downloads/) | ||
* Install [CMake](https://cmake.org/download/) and do | ||
|
||
```bat | ||
:: Get the project. | ||
$ git clone --recursive [email protected]:cpp-sc2/commandcenter.git | ||
$ git clone [email protected]:cpp-sc2/commandcenter.git | ||
$ cd commandcenter | ||
:: Create build directory. | ||
$ mkdir build | ||
$ cd build | ||
:: Create Visual Studio project files. | ||
:: For Visual Studio 2019. | ||
$ cmake ../ -G "Visual Studio 16 2019" | ||
:: For Visual Studio 2017. | ||
$ cmake ../ -G "Visual Studio 15 2017 Win64" | ||
:: For Visual Studio 2022. | ||
$ cmake -B build -G "Visual Studio 17 2022" | ||
:: Build the project using Visual Studio. | ||
:: The binary "CommandCenter_API.exe" should appear in the build/bin/ directory | ||
$ start CommandCenter.sln | ||
:: Launch the bot with the specified path to a SC2 map. | ||
:: Warning: The CommandCenter/bin/BotConfig.txt file must be in the same directory as the .exe to run properly | ||
$ bin\Debug\CommandCenter.exe Ladder2019Season3/AcropolisLE.SC2Map | ||
$ build\bin\Debug\CommandCenter.exe Ladder2019Season3/AcropolisLE.SC2Map | ||
``` | ||
|
||
# Developer Install / Compile Instructions (Linux and OS X) | ||
* OS X: Download and install XCode and Xcode command-line tools. | ||
* Linux: Install 'gcc-c++' with C++14 support and the 'make' utility. | ||
* Install [CMake](https://cmake.org/download/) and do | ||
## OS X | ||
* Download and install XCode and XCode command-line tools. | ||
* Install [CMake](https://cmake.org/download/). | ||
|
||
```bash | ||
# Get the project. | ||
$ git clone --recursive [email protected]:cpp-sc2/commandcenter.git && cd commandcenter | ||
$ git clone [email protected]:cpp-sc2/commandcenter.git && cd commandcenter | ||
|
||
# Generate CMake build tree | ||
$ cmake -B build -G Xcode | ||
|
||
# Build the project. | ||
$ cmake --build build --parallel --verbose | ||
|
||
# Launch the bot with the specified path to a SC2 map. | ||
# Warning: The CommandCenter/bin/BotConfig.txt file must be in the same directory as the executable to run properly | ||
$ build/bin/CommandCenter Ladder2019Season3/AcropolisLE.SC2Map | ||
``` | ||
|
||
# Create build directory. | ||
$ mkdir build && cd build | ||
## Linux | ||
* Install 'gcc-c++' with C++14 support and the 'make' utility. | ||
* Install [CMake](https://cmake.org/download/). | ||
|
||
```bash | ||
# Get the project. | ||
$ git clone [email protected]:cpp-sc2/commandcenter.git && cd commandcenter | ||
|
||
# Generate a Makefile. | ||
# Use 'cmake -DCMAKE_BUILD_TYPE=Debug ../' if debuginfo is needed | ||
$ cmake ../ | ||
# Generate CMake build tree | ||
$ cmake -B build | ||
|
||
# Build the project. | ||
$ VERBOSE=1 cmake --build . --parallel | ||
$ cmake --build build --parallel --verbose | ||
|
||
# Launch the bot with the specified path to a SC2 map. | ||
# Warning: The CommandCenter/bin/BotConfig.txt file must be in the same directory as the executable to run properly | ||
$ bin/Debug/CommandCenter Ladder2019Season3/AcropolisLE.SC2Map | ||
$ build/bin/CommandCenter Ladder2019Season3/AcropolisLE.SC2Map | ||
``` | ||
|
||
# Bot Development | ||
|
Submodule cpp-sc2
deleted from
c295c5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,21 @@ | ||
# All the source files for the bot. | ||
file(GLOB BOT_SOURCES "*.cpp" "*.h" "*.hpp") | ||
|
||
include_directories(SYSTEM | ||
${PROJECT_SOURCE_DIR}/cpp-sc2/include | ||
${PROJECT_SOURCE_DIR}/cpp-sc2/contrib/protobuf/src | ||
${PROJECT_BINARY_DIR}/cpp-sc2/generated | ||
) | ||
|
||
link_directories(${PROJECT_BINARY_DIR}/cpp-sc2/bin) | ||
add_executable(CommandCenter ${BOT_SOURCES}) | ||
|
||
# Show more warnings at compiletime. | ||
if (MSVC) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX-") | ||
target_compile_options(CommandCenter PRIVATE /W4 /EHsc) | ||
else () | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") | ||
target_compile_options(CommandCenter PRIVATE -Wall -Wextra) | ||
endif () | ||
|
||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") | ||
|
||
# Create the executable. | ||
add_executable(CommandCenter ${BOT_SOURCES}) | ||
target_link_libraries(CommandCenter sc2api sc2lib sc2utils sc2protocol civetweb libprotobuf) | ||
target_link_libraries(CommandCenter PRIVATE cpp_sc2) | ||
|
||
if (MINGW) | ||
target_link_libraries(CommandCenter ssp) | ||
endif() | ||
|
||
if (APPLE) | ||
target_link_libraries(CommandCenter "-framework Carbon") | ||
endif () | ||
|
||
# Linux specific. | ||
if (UNIX AND NOT APPLE) | ||
target_link_libraries(CommandCenter pthread dl) | ||
target_link_libraries(CommandCenter PRIVATE ssp) | ||
elseif (APPLE) | ||
target_link_libraries(CommandCenter PRIVATE "-framework Carbon") | ||
elseif (UNIX AND NOT APPLE) # Building on Linux | ||
target_link_libraries(CommandCenter PRIVATE pthread dl) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
message(STATUS "FetchContent: cpp-sc2") | ||
|
||
# Dont build examples in the sc2api submodule. | ||
set(BUILD_API_EXAMPLES OFF CACHE INTERNAL "" FORCE) | ||
|
||
# Dont build tests in the sc2api submodule. | ||
set(BUILD_API_TESTS OFF CACHE INTERNAL "" FORCE) | ||
|
||
# Dont build sc2renderer in the sc2api submodule. | ||
set(BUILD_SC2_RENDERER OFF CACHE INTERNAL "" FORCE) | ||
|
||
FetchContent_Declare( | ||
cpp_sc2 | ||
GIT_REPOSITORY https://github.com/cpp-sc2/cpp-sc2.git | ||
GIT_TAG 6673dc5d8bd69ad9436214a59f8180a8f38f6409 | ||
) | ||
FetchContent_MakeAvailable(cpp_sc2) | ||
|
||
set_target_properties(sc2api PROPERTIES FOLDER cpp-sc2) | ||
set_target_properties(sc2lib PROPERTIES FOLDER cpp-sc2) | ||
set_target_properties(sc2protocol PROPERTIES FOLDER cpp-sc2) | ||
set_target_properties(sc2utils PROPERTIES FOLDER cpp-sc2) |