Skip to content

Instantly share code, notes, and snippets.

@donkaban
Created October 12, 2016 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donkaban/c453aa49be8991e009f24610410fb3ff to your computer and use it in GitHub Desktop.
Save donkaban/c453aa49be8991e009f24610410fb3ff to your computer and use it in GitHub Desktop.
function(PUSH_INCLUDE path)
set(GLOBAL_INCLUDES ${GLOBAL_INCLUDES} ${path})
list(REMOVE_DUPLICATES GLOBAL_INCLUDES)
set(GLOBAL_INCLUDES ${GLOBAL_INCLUDES} CACHE INTERNAL "GLOBAL_INCLUDES")
endfunction(PUSH_INCLUDE)
macro(BUILD_APPS project)
if(BUILD_APPS)
set (libs ${ARGN})
file(GLOB apps_sources ${CMAKE_CURRENT_SOURCE_DIR}/apps/*.cpp)
foreach(file ${apps_sources})
get_filename_component(name ${file} NAME_WE)
add_executable(${name} ${file})
target_link_libraries(${name} ${project} ${libs})
endforeach()
endif()
endmacro()
macro(DECLARE_MODULE name type)
set (libs ${ARGN})
project(${name})
set(project_include_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${project_include_dir})
include_directories(${GLOBAL_INCLUDES})
file(GLOB_RECURSE SOURCES sources/*.cpp)
add_library(${PROJECT_NAME} ${type} ${SOURCES})
PUSH_INCLUDE(${project_include_dir})
target_link_libraries(${PROJECT_NAME} ${libs})
BUILD_APPS(${name} ${libs})
endmacro()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment