From b22094715738213d6b7b2aa0a9bbe85ae2b661da Mon Sep 17 00:00:00 2001 From: cmdc0de Date: Sun, 18 Jun 2023 15:17:40 -0700 Subject: [PATCH 1/2] Goal: Allow someone that uses the cmake_template to have a single varaible file to add * executables * add sub directories * set the default vscode project Thereby not needing to change the cmake files provided by the template. I'm sure there is more to do here but its a start. --- CMakeLists.txt | 7 +++++-- myproject_variables.cmake | 11 +++++++++++ src/CMakeLists.txt | 6 ++++-- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 myproject_variables.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 45e19f03..bdcc39ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,8 @@ endif() # when compiling with PCH enabled set(CMAKE_CXX_EXTENSIONS OFF) +include(myproject_variables.cmake) + # Set the project name and language project( myproject @@ -92,7 +94,8 @@ if(MSVC) endif() # set the startup project for the "play" button in MSVC -set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT intro) +#set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT intro) +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${DEFAULT_EXEC}) if(CMAKE_SKIP_INSTALL_RULES) return() @@ -104,7 +107,7 @@ include(cmake/PackageProject.cmake) # we know we want to ship myproject_package_project( TARGETS - intro + ${PROJ_EXEC1} myproject_options myproject_warnings # FIXME: this does not work! CK diff --git a/myproject_variables.cmake b/myproject_variables.cmake new file mode 100644 index 00000000..9214e16f --- /dev/null +++ b/myproject_variables.cmake @@ -0,0 +1,11 @@ +set(PROJ_EXEC1 "intro") + +#directories under src that will be added as subdirectories to the project +set(MY_PROJECT_SUBDIRECTORIES "ftxui_sample;sample_library") + +set(DEFAULT_EXEC ${PROJ_EXEC1} CACHE STRING "Default executable to build") + +#set(MY_PROJECT_TARGETS "${PROJ_EXEC1} ${SERVER_APP}") +set(MY_PROJECT_TARGETS "${PROJ_EXEC1}") + +MESSAGE(STATUS "MY PROJECT TARGETS = ${MY_PROJECT_TARGETS}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f92a9d6..76a9c4a5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,2 +1,4 @@ -add_subdirectory(sample_library) -add_subdirectory(ftxui_sample) +foreach(d ${MY_PROJECT_SUBDIRECTORIES}) + MESSAGE(STATUS "Adding subdirectory: ${d}") + add_subdirectory(${d}) +endforeach() From ef9c51c2fedfd833d6264ef8fa0cffb307c906ba Mon Sep 17 00:00:00 2001 From: cmdc0de Date: Sat, 14 Oct 2023 17:02:56 -0700 Subject: [PATCH 2/2] fixes so when the template janitor runs it doesn't search and replace out the new variables file --- CMakeLists.txt | 2 +- myproject_variables.cmake => project_variables.cmake | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename myproject_variables.cmake => project_variables.cmake (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index bdcc39ad..56fc620c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ endif() # when compiling with PCH enabled set(CMAKE_CXX_EXTENSIONS OFF) -include(myproject_variables.cmake) +include(project_variables.cmake) # Set the project name and language project( diff --git a/myproject_variables.cmake b/project_variables.cmake similarity index 100% rename from myproject_variables.cmake rename to project_variables.cmake