From 405ba80d8d2c757e5e4ddcaa408b9b545dc7d0e5 Mon Sep 17 00:00:00 2001 From: Nicholas O'Connor Date: Fri, 24 Mar 2017 22:41:33 -0700 Subject: [PATCH] moved source finding logic to its own function for easy reuse later --- CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 405bf8d..a3c8acd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,17 +51,23 @@ endforeach(cogfile) add_custom_target(cog ALL DEPENDS ${coggedfiles}) -set(cellar_LIBRARIES) -function(cellar_library target) +function(get_sources globtarget output) file(GLOB_RECURSE targetsources RELATIVE "${CMAKE_SOURCE_DIR}" - "${CMAKE_SOURCE_DIR}/src/${target}/*.cpp") + "${CMAKE_SOURCE_DIR}/${globtarget}") file(GLOB_RECURSE targetcoggedsources RELATIVE "${CMAKE_SOURCE_DIR}" - "${CMAKE_SOURCE_DIR}/src/${target}/*.cpp.cog") + "${CMAKE_SOURCE_DIR}/${globtarget}.cog") foreach(targetcog ${targetcoggedsources}) string(REGEX REPLACE ".cog\$" "" this "${targetcog}") set(targetsources ${targetsources} ${this}) endforeach(targetcog) + set(${output} ${targetsources} PARENT_SCOPE) +endfunction(get_sources) + +set(cellar_LIBRARIES) +function(cellar_library target) + get_sources("src/${target}/*.cpp" targetsources) + add_library(${target} SHARED ${targetsources}) add_dependencies(${target} cog)