enkiTS
enkiTS copied to clipboard
adding enkiTS as a static library to another project
I have a project with the following setup in CMakeLists.txt:
add_subdirectory(${ENKITS_DIR} "enkiTS")
add_executable(mytest01 main.cpp main.h tasks_enkits.cpp)
target_link_libraries(mytest01 PRIVATE shared_stuff enkiTS )
where ENKITS_DIR is a CMake var, a path to the library folder, outside of my project source path.
the problem is mytest01 doesn't compile, because this header file can't be found:
#include "TaskScheduler.h"
There are two important things that have to be mentioned:
- the very same setup works with various other libraries like raylib and spdlog
- my project compiles just fine if the following line (it's the second one from the bottom) is applied to enkiTS' CMakeLists.txt:
if( ENKITS_BUILD_SHARED )
add_library( enkiTS SHARED ${ENKITS_SRC} )
target_compile_definitions( enkiTS PRIVATE ENKITS_BUILD_DLL=1 )
target_compile_definitions( enkiTS INTERFACE ENKITS_DLL=1 )
if( UNIX )
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()
endif ()
else()
message(STATUS "enkiTS as a static library")
add_library( enkiTS STATIC ${ENKITS_SRC} )
target_include_directories(enkiTS PUBLIC "${PROJECT_SOURCE_DIR}/src") #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
endif()
I have little experience with CMake so maybe there is a problem with my project setup (although it does work with other libs)?
Thanks for filing the issue - I'll look into adding target_include_directories (I think this would need to be done for both static and dynamic library builds), for now you can add include_directories("enkiTS/src") to your CmakeLists.txt to add the appropriate directory to your build includes, as per the one in the enkiTSExamples project.
ok, great, thank you!