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}) add_executable(${GAME} ${GAME_SOURCES})
target_include_directories(${GAME} PRIVATE target_include_directories(${GAME} PRIVATE
"src" "src")
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/vendor/ruc/src")
target_link_libraries(${GAME} ${ENGINE}) target_link_libraries(${GAME} ${ENGINE})
target_precompile_headers(${GAME} REUSE_FROM ${ENGINE}) target_precompile_headers(${GAME} REUSE_FROM ${ENGINE})
@ -25,5 +23,5 @@ target_precompile_headers(${GAME} REUSE_FROM ${ENGINE})
# Add 'make run' target # Add 'make run' target
add_custom_target(run add_custom_target(run
COMMAND ${GAME} 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") file(GLOB_RECURSE ENGINE_SOURCES "${ENGINE}/*.cpp")
add_library(${ENGINE} ${ENGINE_SOURCES}) add_library(${ENGINE} ${ENGINE_SOURCES})
target_include_directories(${ENGINE} PRIVATE target_include_directories(${ENGINE} PUBLIC
"." "."
"../vendor/entt/src" "../vendor/entt/src"
"../vendor/glad/include"
"../vendor/glfw/include" "../vendor/glfw/include"
"../vendor/glm" "../vendor/glm"
"../vendor/json/include" "../vendor/json/include"
"../vendor/lua"
"../vendor/ruc/src" "../vendor/ruc/src"
"../vendor/sol2/include" "../vendor/sol2/include"
"../vendor/stb") "../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}) set(ENGINE_SOURCES ${GLAD} ${LUA})
add_library(${ENGINE}-dependencies ${ENGINE_SOURCES}) add_library(${ENGINE}-dependencies ${ENGINE_SOURCES})
target_include_directories(${ENGINE}-dependencies PRIVATE target_include_directories(${ENGINE}-dependencies PUBLIC
"glad/include" "glad/include"
"lua") "lua")
target_link_libraries(${ENGINE}-dependencies glfw ruc) target_link_libraries(${ENGINE}-dependencies glfw ruc)

Loading…
Cancel
Save