I’m trying setup a simple project in CLion on OS X with cmake.
This is how my project is structured. I have two blocks - CoC-Core and CoC-Assets. CoC-Assets needs a header file from CoC-Core. I’ve setup the cmake files for these two blocks based on the TUIO and OSC example (looking at the documentation here).
When I run the build, CoC-Assets complains that cocCore.h is not found.
Here are my cmake files.
## CoC-CoreConfig.cmake
if( NOT TARGET CoC-Core )
get_filename_component( COC_CORE_SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../src" ABSOLUTE )
FILE(GLOB COC_CORE_SOURCES ${COC_CORE_SOURCE_PATH}/*.cpp)
add_library( CoC-Core ${COC_CORE_SOURCES} )
target_include_directories( CoC-Core PUBLIC "${COC_CORE_SOURCE_PATH}" )
# If Cinder included from this block:
target_include_directories( CoC-Core SYSTEM BEFORE PUBLIC "${CINDER_PATH}/include" )
if( NOT TARGET cinder )
include( "${CINDER_PATH}/proj/cmake/configure.cmake" )
find_package( cinder REQUIRED PATHS
"${CINDER_PATH}/${CINDER_LIB_DIRECTORY}"
"$ENV{CINDER_PATH}/${CINDER_LIB_DIRECTORY}" )
endif()
target_link_libraries( CoC-Core PRIVATE cinder )
endif()
## CoC-AssetsConfig.cmake
if( NOT TARGET CoC-Assets )
get_filename_component( COC_ASSETS_SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../src" ABSOLUTE )
FILE(GLOB COC_ASSETS_SOURCES ${COC_ASSETS_SOURCE_PATH}/*.cpp)
add_library( CoC-Assets ${COC_ASSETS_SOURCES} )
target_include_directories( CoC-Assets PUBLIC "${COC_ASSETS_SOURCE_PATH}" )
# If Cinder included from this block:
target_include_directories( CoC-Assets SYSTEM BEFORE PUBLIC "${CINDER_PATH}/include" )
if( NOT TARGET cinder )
include( "${CINDER_PATH}/proj/cmake/configure.cmake" )
find_package( cinder REQUIRED PATHS
"${CINDER_PATH}/${CINDER_LIB_DIRECTORY}"
"$ENV{CINDER_PATH}/${CINDER_LIB_DIRECTORY}" )
endif()
# Add CoC-Core block as a dependency
get_filename_component( COC_CORE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../../CoC-Core/proj/cmake" ABSOLUTE )
find_package( CoC-Core REQUIRED PATHS "${COC_CORE_MODULE_PATH}" )
if (CoC-Core_FOUND)
# target_include_directories( CoC-Assets PUBLIC ${COC_CORE_SOURCE_PATH} ABSOLUTE ) # <-- this line works
add_dependencies( CoC-Assets CoC-Core ) # <-- this does not
endif()
target_link_libraries( CoC-Assets PRIVATE cinder)
endif()
I can tell that the find_package
works correctly because CoC-Core_FOUND
is true. However, using add_dependencies
(as per the TUIO/OSC example) does not seem to get the include directories of CoC-Core. If I manually include the directories via target_include_directories
, the build is successful.
I’m not sure what I’m doing wrong. Any suggestions will be much appreciated. Thanks!