Browse Source

CMake: Populate list of required include directories for library targets

PUBLIC items will populate the INTERFACE_INCLUDE_DIRECTORIES property of
<target>. This property is a list of public include directories
requirements for a library.

Targets may populate this property to publish the include directories
required to compile against the headers for the target.
master
Riyyi 2 years ago
parent
commit
26cd35d679
  1. 8
      example/CMakeLists.txt
  2. 4
      src/CMakeLists.txt
  3. 2
      vendor/CMakeLists.txt

8
example/CMakeLists.txt

@ -13,9 +13,7 @@ file(GLOB_RECURSE GAME_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
add_executable(${GAME} ${GAME_SOURCES})
target_include_directories(${GAME} PRIVATE
"src"
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/vendor/ruc/src")
"src")
target_link_libraries(${GAME} ${ENGINE})
target_precompile_headers(${GAME} REUSE_FROM ${ENGINE})
@ -25,5 +23,5 @@ target_precompile_headers(${GAME} REUSE_FROM ${ENGINE})
# Add 'make run' target
add_custom_target(run
COMMAND ${GAME}
WORKING_DIRECTORY ".."
)
WORKING_DIRECTORY "..")
add_dependencies(run ${ENGINE})

4
src/CMakeLists.txt

@ -1,14 +1,12 @@
file(GLOB_RECURSE ENGINE_SOURCES "${ENGINE}/*.cpp")
add_library(${ENGINE} ${ENGINE_SOURCES})
target_include_directories(${ENGINE} PRIVATE
target_include_directories(${ENGINE} PUBLIC
"."
"../vendor/entt/src"
"../vendor/glad/include"
"../vendor/glfw/include"
"../vendor/glm"
"../vendor/json/include"
"../vendor/lua"
"../vendor/ruc/src"
"../vendor/sol2/include"
"../vendor/stb")

2
vendor/CMakeLists.txt vendored

@ -18,7 +18,7 @@ list(REMOVE_ITEM LUA "${CMAKE_CURRENT_SOURCE_DIR}/lua/lua/lua.c") # Do not co
set(ENGINE_SOURCES ${GLAD} ${LUA})
add_library(${ENGINE}-dependencies ${ENGINE_SOURCES})
target_include_directories(${ENGINE}-dependencies PRIVATE
target_include_directories(${ENGINE}-dependencies PUBLIC
"glad/include"
"lua")
target_link_libraries(${ENGINE}-dependencies glfw ruc)

Loading…
Cancel
Save