Extracted Colobot executable target to a separate directory

dev
Tomasz Kapuściński 2023-08-09 14:42:24 +02:00
parent 6f05280ccb
commit 1ee0790785
5 changed files with 40 additions and 28 deletions

1
.gitignore vendored
View File

@ -17,7 +17,6 @@ CMakeDoxygenDefaults.cmake
/Doxyfile
# Ignore targets
/colobot
/src/CBot/libCBot.so
# Ignore local data

View File

@ -235,9 +235,6 @@ option(DEV_BUILD "Enable development build (enables some debugging tools, local
# PLEASE DO NOT USE ON UNOFFICIAL BUILDS. Thanks.
option(OFFICIAL_COLOBOT_BUILD "Official build (changes crash screen text)" OFF)
# Hide console on Windows (useful for release builds)
option(HIDE_CONSOLE "Hide console" OFF)
# Hardcode relative paths instead of absolute paths
option(USE_RELATIVE_PATHS "Generate relative paths from absolute paths" OFF)
@ -450,6 +447,9 @@ add_subdirectory(CBot)
# Subdirectory with sources
add_subdirectory(src)
# Add Colobot executable
add_subdirectory(colobot)
add_subdirectory(po)
if(DESKTOP)

37
colobot/CMakeLists.txt Normal file
View File

@ -0,0 +1,37 @@
# Hide console on Windows (useful for release builds)
option(COLOBOT_HIDE_CONSOLE "Hide console" OFF)
add_executable(colobot)
target_sources(colobot PRIVATE
src/main.cpp
)
if(PLATFORM_WINDOWS)
target_sources(colobot PRIVATE ${PROJECT_BINARY_DIR}/desktop/colobot.rc)
endif()
target_link_libraries(colobot colobotbase SDL2::Main)
if(COLOBOT_HIDE_CONSOLE)
set_target_properties(colobot PROPERTIES WIN32_EXECUTABLE TRUE)
endif()
# Install
install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
if(MSVC)
install(FILES $<TARGET_PDB_FILE:colobot>
CONFIGURATIONS Debug RelWithDebInfo
DESTINATION ${COLOBOT_INSTALL_BIN_DIR} OPTIONAL)
endif()
if(NOT CBOT_STATIC)
set_target_properties(colobot PROPERTIES
INSTALL_RPATH ${COLOBOT_INSTALL_LIB_DIR})
endif()
# Linter-specific
if(COLOBOT_LINT_BUILD)
add_fake_header_sources("src" colobot)
endif()

View File

@ -576,31 +576,7 @@ endif()
set(COLOBOT_LIBS ${LIBS} PARENT_SCOPE)
# Targets
if(HIDE_CONSOLE)
add_executable(colobot WIN32 app/main.cpp)
else()
add_executable(colobot app/main.cpp)
endif()
if(PLATFORM_WINDOWS)
target_sources(colobot PRIVATE ../desktop/colobot.rc)
endif()
target_link_libraries(colobot colobotbase SDL2::Main)
# Install
install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
if(MSVC)
install(FILES $<TARGET_PDB_FILE:colobot> CONFIGURATIONS Debug RelWithDebInfo DESTINATION ${COLOBOT_INSTALL_BIN_DIR} OPTIONAL)
endif()
if(NOT CBOT_STATIC)
set_target_properties(colobot PROPERTIES INSTALL_RPATH ${COLOBOT_INSTALL_LIB_DIR})
endif()
# Linter-specific
if(COLOBOT_LINT_BUILD)
add_fake_header_sources("src" colobotbase)
add_fake_header_sources("src" colobot)
endif()