diff options
author | rtk0c <[email protected]> | 2022-05-30 17:03:20 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-05-30 17:03:20 -0700 |
commit | e66286ebe30afc9acc4531fc2bea29b7fb924f93 (patch) | |
tree | fa6b76554c3eb88bc8f088fbab68e20c40118ca7 /CMakeLists.txt | |
parent | 366ef5a5450c6e0e680c924c3454943a9ae9814d (diff) |
Changeset: 56 Buildsystem cleanup: change to layered structure for different targets
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 111 |
1 files changed, 58 insertions, 53 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a418491..e9a1932 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,9 +4,9 @@ project(ProjectBrussel LANGUAGES C CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -include(buildtools/cmake/Exceptions.cmake) -include(buildtools/cmake/RTTI.cmake) -include(buildtools/cmake/Win32Subsystem.cmake) +include(cmake/Exceptions.cmake) +include(cmake/RTTI.cmake) +include(cmake/Win32Subsystem.cmake) find_package(OpenGL REQUIRED) add_subdirectory(3rdparty/glfw) @@ -16,12 +16,15 @@ add_subdirectory(3rdparty/imguicolortextedit) add_subdirectory(3rdparty/tracy) # ============================================================================== -# Standalone library things +# Layer 10 (standalone, throw-into-the-buildsystem style) -file(GLOB_RECURSE things_common_SOURCES source-common/*.c source-common/*.cpp) -add_library(things_common OBJECT ${things_common_SOURCES}) +file(GLOB_RECURSE 10-common_SOURCES + source/10-common/*.c + source/10-common/*.cpp +) +add_library(10-common OBJECT ${10-common_SOURCES}) -set_target_properties(things_common PROPERTIES +set_target_properties(10-common PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF @@ -30,63 +33,68 @@ set_target_properties(things_common PROPERTIES UNITY_BUILD OFF ) -target_include_directories(things_common PUBLIC source-common) -target_link_libraries(things_common PUBLIC +target_include_directories(10-common PUBLIC source/10-common) +target_link_libraries(10-common PUBLIC # External dependencies ${CONAN_LIBS} glm::glm ) # ============================================================================== -# Codegen +# Layer 20 (building tools) -# NOTE: delibrately not recursive, see README.md in the folder for details -file(GLOB codegen_SOURCES buildtools/codegen/*.c buildtools/codegen/*.cpp) -add_executable(codegen ${codegen_SOURCES}) +file(GLOB_RECURSE 20-codegen-runtime_SOURCES + source/20-codegen-runtime/*.c + source/20-codegen-runtime/*.cpp +) +add_library(20-codegen-runtime OBJECT ${20-codegen-runtime_SOURCES}) -set_target_properties(codegen PROPERTIES +set_target_properties(20-codegen-runtime PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF - UNITY_BUILD OFF ) -target_link_libraries(codegen PRIVATE +target_include_directories(20-codegen-runtime PUBLIC source/20-codegen-runtime) +target_link_libraries(20-codegen-runtime PUBLIC # External dependencies ${CONAN_LIBS} # Project internal components - things_common + 10-common ) -target_flag_exceptions(codegen ON) -target_flag_rtti(codegen OFF) - -option(BRUSSEL_CODEGEN_DEBUG_PRINT "Enable debug printing in the code generator or not." OFF) -if(BRUSSEL_CODEGEN_DEBUG_PRINT) - target_compile_definitions(codegen PRIVATE CODEGEN_DEBUG_PRINT=1) -endif() - -file(GLOB_RECURSE things_codegen_companion_SOURCES buildtools/codegen-companion/*.c buildtools/codegen-companion/*.cpp) -add_library(things_codegen_companion OBJECT ${things_codegen_companion_SOURCES}) +# NOTE: delibrately not recursive, because this target can contain non-source files with .cpp extensions in the folder +file(GLOB 20-codegen-compiler_SOURCES + source/20-codegen-compiler/*.c + source/20-codegen-compiler/*.cpp +) +add_executable(20-codegen-compiler ${20-codegen-compiler_SOURCES}) -set_target_properties(things_codegen_companion PROPERTIES +set_target_properties(20-codegen-compiler PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF ) -target_include_directories(things_codegen_companion PUBLIC buildtools/codegen-companion) -target_link_libraries(things_codegen_companion PUBLIC +target_link_libraries(20-codegen-compiler PRIVATE # External dependencies ${CONAN_LIBS} # Project internal components - things_common + 10-common ) +target_flag_exceptions(20-codegen-compiler ON) +target_flag_rtti(20-codegen-compiler OFF) + +option(BRUSSEL_CODEGEN_DEBUG_PRINT "Enable debug printing in the code generator or not." OFF) +if(BRUSSEL_CODEGEN_DEBUG_PRINT) + target_compile_definitions(codegen PRIVATE CODEGEN_DEBUG_PRINT=1) +endif() + # ============================================================================== -# Target creation code +# Layer 30 (final products) function(add_projectized_executable) # Add a library target @@ -121,10 +129,10 @@ function(add_projectized_executable) ) target_link_libraries(${arg_TARGET_NAME} PRIVATE - things_common + 10-common ) - set_target_properties(brussel PROPERTIES + set_target_properties(${arg_TARGET_NAME} PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF @@ -133,7 +141,7 @@ function(add_projectized_executable) if(arg_ENABLE_CODEGEN) set(var_OUTPUT_DIR ${CMAKE_BINARY_DIR}/generated/${arg_TARGET_NAME}) target_include_directories(${arg_TARGET_NAME} PRIVATE ${var_OUTPUT_DIR}) - target_link_libraries(${arg_TARGET_NAME} PRIVATE things_codegen_companion) + target_link_libraries(${arg_TARGET_NAME} PRIVATE 20-codegen-runtime) foreach(var_HEADER IN LISTS var_HEADERS) get_filename_component(var_HEADER_ABS "${var_HEADER}" ABSOLUTE) @@ -154,7 +162,7 @@ function(add_projectized_executable) # Generate the files add_custom_command( OUTPUT ${var_OUTPUT_HEADERS} ${var_OUTPUT_SOURCES} - COMMAND codegen ${var_OUTPUT_DIR}/generated single:${var_HEADER} + COMMAND 20-codegen-compiler ${var_OUTPUT_DIR}/generated single:${var_HEADER} DEPENDS ${var_HEADER} ) @@ -164,33 +172,30 @@ function(add_projectized_executable) endif() endfunction() -# ============================================================================== -# The main game - add_projectized_executable( - TARGET_NAME brussel - TARGET_SOURCE_DIR source/ + TARGET_NAME 30-game + TARGET_SOURCE_DIR source/30-game/ ENABLE_CODEGEN ON ) set_source_files_properties( source/main.cpp -TARGET_DIRECTORY brussel +TARGET_DIRECTORY 30-game PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON ) -set_target_properties(brussel PROPERTIES +set_target_properties(30-game PROPERTIES UNITY_BUILD_MODE BATCH UNITY_BUILD_UNIQUE_ID "ProjectBrussel_UNITY_ID" ) -target_compile_definitions(brussel PRIVATE +target_compile_definitions(30-game PRIVATE RAPIDJSON_HAS_STDSTRING=1 IMGUI_DISABLE_OBSOLETE_FUNCTIONS ) -target_link_libraries(brussel PRIVATE +target_link_libraries(30-game PRIVATE # External dependencies ${CONAN_LIBS} OpenGL::GL @@ -203,13 +208,13 @@ target_link_libraries(brussel PRIVATE # Project internal components ) -target_flag_exceptions(brussel ON) -target_flag_rtti(brussel ON) -target_use_windows_subsystem(brussel) +target_flag_exceptions(30-game ON) +target_flag_rtti(30-game ON) +target_use_windows_subsystem(30-game) option(BRUSSEL_ENABLE_PROFILING "Whether profiling support is enabled or not." OFF) if(BRUSSEL_ENABLE_PROFILING) - target_compile_definitions(brussel + target_compile_definitions(30-game PRIVATE TRACY_ENABLE ) @@ -217,7 +222,7 @@ endif() option(BRUSSEL_ENABLE_DEV_ENC "Enable dev environment features or not." ON) if(BRUSSEL_ENABLE_DEV_ENC) - target_compile_definitions(brussel + target_compile_definitions(30-game PRIVATE BRUSSEL_DEV_ENV=1 ) @@ -225,7 +230,7 @@ endif() option(BRUSSEL_ENABLE_EDITOR "Enable editor support or not." ON) if(BRUSSEL_ENABLE_EDITOR) - target_compile_definitions(brussel + target_compile_definitions(30-game PRIVATE BRUSSEL_ENABLE_EDITOR=1 ) @@ -233,12 +238,12 @@ endif() option(BRUSSEL_ENABLE_ASAN "Enable AddressSanitizer or not." OFF) if(BRUSSEL_ENABLE_ASAN) - target_compile_options(brussel + target_compile_options(30-game PRIVATE -fsanitize=address -fno-omit-frame-pointer ) - target_link_options(brussel + target_link_options(30-game PRIVATE -fsanitize=address -fno-omit-frame-pointer |