From 1ee0790785c63bda8119c029966ba82b24e13845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Wed, 9 Aug 2023 14:42:24 +0200 Subject: [PATCH] Extracted Colobot executable target to a separate directory --- .gitignore | 1 - CMakeLists.txt | 6 ++--- colobot/CMakeLists.txt | 37 +++++++++++++++++++++++++++++++ {src/app => colobot/src}/main.cpp | 0 src/CMakeLists.txt | 24 -------------------- 5 files changed, 40 insertions(+), 28 deletions(-) create mode 100644 colobot/CMakeLists.txt rename {src/app => colobot/src}/main.cpp (100%) diff --git a/.gitignore b/.gitignore index e340866c..8af35f7a 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,6 @@ CMakeDoxygenDefaults.cmake /Doxyfile # Ignore targets -/colobot /src/CBot/libCBot.so # Ignore local data diff --git a/CMakeLists.txt b/CMakeLists.txt index 87e13534..08126f09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/colobot/CMakeLists.txt b/colobot/CMakeLists.txt new file mode 100644 index 00000000..9008d09c --- /dev/null +++ b/colobot/CMakeLists.txt @@ -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 $ + 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() diff --git a/src/app/main.cpp b/colobot/src/main.cpp similarity index 100% rename from src/app/main.cpp rename to colobot/src/main.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f3e6bcae..de93ac80 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 $ 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()