Share

Cgreen

Tracker: Patches

5 Fix cmake sub directory builds - ID: 2863558
Last Update: Comment added ( joaohf )

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

Index: src/CMakeLists.txt
===================================================================
--- 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"
)

Index: CMakeLists.txt
===================================================================
--- 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


Erik Fears ( strtok ) - 2009-09-21 15:21

5

Open

None

João Henrique F. de Freitas

None

None

Public


Comment ( 1 )




Date: 2009-10-17 20:07
Sender: joaohfProject Admin

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}
)




Log in to comment.

Attached File

No Files Currently Attached

Change ( 1 )

Field Old Value Date By
assigned_to nobody 2009-10-12 18:30 joaohf