If cgreen is added as a sub project of any other project, then the cgreen build fails because it's not settings its project directories in relation to a parent project. CGreen should be using PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR for any relative paths
--- src/CMakeLists.txt (revision 317)
+++ src/CMakeLists.txt (working copy)
@@ -1,11 +1,9 @@
-project(cgreen-library C)
-
find_package(FLEX)
set(CGREEN_PUBLIC_INCLUDE_DIRS
- ${CMAKE_SOURCE_DIR}/include
+ ${PROJECT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_SOURCE_DIR}
+ ${PROJECT_SOURCE_DIR}
CACHE INTERNAL "cgreen public include directories"
)
--- CMakeLists.txt (revision 317)
+++ CMakeLists.txt (working copy)
@@ -11,7 +11,7 @@
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH
- ${CMAKE_SOURCE_DIR}/cmake/Modules
+ ${PROJECT_SOURCE_DIR}/cmake/Modules
)
# add definitions
Hello Erik,
See the patch below and tell me what you think.
Your patch don't work because
# grep PUBLIC_ CMakeCache.txt
CGREEN_PUBLIC_INCLUDE_DIRS:INTERNAL=/home/joaohf/opensource/cgreen/correcao_cmake/src/include;/home/joaohf/opensource/cgreen/correcao_cmake/src;/home/joaohf/opensource/cgreen/correcao_cmake/src
PUBLIC_INCLUDE_DIRS has set with cgreen/src/include. I think the correct is cgreen/include.
=== CMakeLists.txt
--- CMakeLists.txt (revision 328)
+++ CMakeLists.txt (local)
@@ -11,7 +11,7 @@
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH
- ${CMAKE_SOURCE_DIR}/cmake/Modules
+ ${PROJECT_SOURCE_DIR}/cmake/Modules
)
# add definitions
@@ -34,6 +34,13 @@
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
endif (WIN32)
+set(CGREEN_PUBLIC_INCLUDE_DIRS
+ ${PROJECT_SOURCE_DIR}/include
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${PROJECT_SOURCE_DIR}
+ CACHE INTERNAL "cgreen public include directories"
+)
+
# check subdirectories
add_subdirectory(doc)
add_subdirectory(include)
=== src/CMakeLists.txt
==================================================================
--- src/CMakeLists.txt (revision 328)
+++ src/CMakeLists.txt (local)
@@ -2,13 +2,6 @@
find_package(FLEX)
-set(CGREEN_PUBLIC_INCLUDE_DIRS
- ${CMAKE_SOURCE_DIR}/include
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_SOURCE_DIR}
- CACHE INTERNAL "cgreen public include directories"
-)
-
set(CGREEN_PRIVATE_INCLUDE_DIRS
${CMAKE_BINARY_DIR}
)
Does not seem to be a problem anymore