diff --git a/CMakeLists.txt b/CMakeLists.txt index d869b7f..dde5b5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,11 +2,12 @@ cmake_minimum_required(VERSION 3.29) project(cplusplus-primer) +include(ExternalProject) + foreach(subproject example_1 example_2 example_3 example_4 library_1) - message(STATUS "Creating '${CMAKE_CURRENT_BINARY_DIR}/build_${subproject}'") - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build_${subproject}) - add_custom_target(cplusplus-primer-${subproject} ALL - COMMAND ${CMAKE_COMMAND} -B ${CMAKE_CURRENT_BINARY_DIR}/build_${subproject} -S ${CMAKE_CURRENT_SOURCE_DIR}/${subproject} - COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/build_${subproject} + ExternalProject_Add(${subproject} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${subproject} + STEP_TARGETS build + INSTALL_COMMAND "" ) endforeach()