Skip to content

Instantly share code, notes, and snippets.

@Reflexe
Created October 22, 2019 20:13
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 Reflexe/51a43b752e5798ac28560651882a8e56 to your computer and use it in GitHub Desktop.
Save Reflexe/51a43b752e5798ac28560651882a8e56 to your computer and use it in GitHub Desktop.
diff --git a/cmake/process_project.txt b/cmake/process_project.txt
index 5c45f6e..261e992 100644
--- a/cmake/process_project.txt
+++ b/cmake/process_project.txt
@@ -6,8 +6,6 @@ MESSAGE(STATUS "Configuring ${PROJECT_NAME} ${VERSION}...")
# directories
SET(src_base "${CMAKE_CURRENT_SOURCE_DIR}/src/")
-include_directories("${CMAKE_CURRENT_BINARY_DIR}/src/") # for config.h
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") # TODO: libraries only?
# special headers -> src?
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index 7296675..922b1de 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -6,7 +6,15 @@ file(GLOB ringbuffer_lib_hdr ${src_dir}../../include/ringbuffer/*.h)
add_library(ringbuffer SHARED ${ringbuffer_lib_src} ${ringbuffer_lib_hdr})
generate_export_header(ringbuffer)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+target_include_directories(ringbuffer PUBLIC
+ # src, for config.h
+ "${CMAKE_CURRENT_BINARY_DIR}/../"
+ # root/include for lib headers
+ "${CMAKE_CURRENT_SOURCE_DIR}/../../include"
+ # this bin dir for the export header.
+ "${CMAKE_CURRENT_BINARY_DIR}"
+)
install(TARGETS ringbuffer
LIBRARY DESTINATION ${INSTALL_LIB_DIR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment