Skip to content

Commit

Permalink
build: Add build options
Browse files Browse the repository at this point in the history
  • Loading branch information
oboukli committed Jan 4, 2025
1 parent 179ae4e commit 86f495a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ emscripten_cache/
# vcpkg

vcpkg/
vcpkg_installed/
28 changes: 26 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

option(BUILD_TROMINO2D "Build Tromino2D library and executable" ON)
option(BUILD_TEST_DRIVER "Build development test driver" ON)
option(BUILD_BENCHMARK_DRIVER "Build development benchmark driver" ON)

if(BUILD_TROMINO2D)
list(APPEND VCPKG_MANIFEST_FEATURES "tromino2d")
endif()

if(BUILD_TEST_DRIVER)
list(APPEND VCPKG_MANIFEST_FEATURES "test-driver")
endif()

if(BUILD_BENCHMARK_DRIVER)
list(APPEND VCPKG_MANIFEST_FEATURES "benchmark-driver")
endif()

project(
Tromino
LANGUAGES C CXX
Expand Down Expand Up @@ -113,6 +129,7 @@ source_group(
FILES ${tromino_validation_sources}
)

if(BUILD_TROMINO2D)
find_package(SDL2 CONFIG REQUIRED)
add_library(
tromino_gfx2d
Expand Down Expand Up @@ -164,6 +181,7 @@ target_link_libraries(
PUBLIC
$<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static>
)
endif()

add_executable(
tromino
Expand Down Expand Up @@ -230,6 +248,7 @@ target_link_libraries(
PRIVATE tromino_validation
)

if(BUILD_TROMINO2D)
add_executable(
tromino2d
)
Expand Down Expand Up @@ -284,7 +303,9 @@ target_link_libraries(
PRIVATE tromino_validation
PRIVATE tromino_gfx2d
)
endif()

if(BUILD_TEST_DRIVER)
enable_testing()
find_package(Boost CONFIG REQUIRED COMPONENTS unit_test_framework)

Expand Down Expand Up @@ -318,7 +339,11 @@ target_link_libraries(
PRIVATE tromino_core
PRIVATE tromino_validation
)
endif()

if(BUILD_BENCHMARK_DRIVER)
find_package(nameof CONFIG REQUIRED)
find_package(nanobench CONFIG REQUIRED)
add_executable(
benchmark_driver
)
Expand All @@ -327,8 +352,6 @@ target_sources(
PRIVATE
"${CMAKE_SOURCE_DIR}/benchmark/core/tromino_benchmark.cpp"
)
find_package(nameof CONFIG REQUIRED)
find_package(nanobench CONFIG REQUIRED)
target_link_libraries(
benchmark_driver
PRIVATE nameof::nameof
Expand All @@ -338,3 +361,4 @@ target_link_libraries(
benchmark_driver
PRIVATE tromino_core
)
endif()
6 changes: 3 additions & 3 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"features": {
"tromino2d": {
"description": "client game executable",
"description": "Tromino2D library and executable",
"dependencies": [
"sdl2"
]
},
"test-driver": {
"description": "development tests",
"description": "Development test driver",
"dependencies": [
"boost-test"
]
},
"benchmark-driver": {
"description": "multiplayer server executable",
"description": "Development benchmark driver",
"dependencies": [
"nameof",
"nanobench"
Expand Down

0 comments on commit 86f495a

Please sign in to comment.