Skip to content

Instantly share code, notes, and snippets.

@domargan
Created November 6, 2017 22:35
Show Gist options
  • Save domargan/2a7fa793ada4ce2789c5885d7a2c427d to your computer and use it in GitHub Desktop.
Save domargan/2a7fa793ada4ce2789c5885d7a2c427d to your computer and use it in GitHub Desktop.
One (hacky) CMakeLists.txt to rule them all...
# Credits: sakra @ https://stackoverflow.com/a/6925256
cmake_minimum_required(VERSION 3.0)
project (Foo)
file(GLOB_RECURSE Foo_SOURCES "src/*.cpp")
file(GLOB_RECURSE Foo_HEADERS "src/*.h")
set (Foo_INCLUDE_DIRS "")
foreach (_headerFile ${Foo_HEADERS})
get_filename_component(_dir ${_headerFile} PATH)
list (APPEND Foo_INCLUDE_DIRS ${_dir})
endforeach()
list(REMOVE_DUPLICATES Foo_INCLUDE_DIRS)
add_executable (FooExe ${Foo_SOURCES})
target_include_directories(FooExe PRIVATE ${Foo_INCLUDE_DIRS})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment