I can't get my cmake project running. It should build a library (Core) and then add this library to a new shared library. The problem is that the resulting library does not seem to link correctly against the executable.
fatal error: JNF_NEAT/body.h: No such file or directory
I have a CMake project which is structured as follows:
root
-> CMakeLists.txt
-> Core/
-> CMakeLists.txt
-> Sources/
-> Examples/
-> CMakeLists.txt
-> Example1/
-> CMakeLists.txt
-> Sources/
root/CMakeLists.txt
cmake_minimum_required(VERSION 3.2.2)
project(JNF_NEAT)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out/examples)
add_subdirectory(Core)
add_library(JNF_NEAT SHARED $<TARGET_OBJECTS:Core>)
target_link_libraries(JNF_NEAT -lstdc++fs)
add_subdirectory(Examples)
root/Core/CMakeLists.txt
file(GLOB SOURCES Sources/*.cpp Sources/*.h)
add_library(Core OBJECT ${SOURCES})
root/Examples/CMakeLists.txt
add_subdirectory(XOR)
root/Examples/XOR/CMakeLists.txt
include_directories(../../out/lib)
file(GLOB SOURCES Sources/*.cpp Sources/*.h)
add_executable(XOR_EXAMPLE ${SOURCES})
target_link_libraries(XOR_EXAMPLE JNF_NEAT)
The entire source code is available here.
Edit #1
I tried setting target_include_directories(XOR_EXAMPLE BEFORE PUBLIC ../../out/lib) before target_link_libraries
I also tried setting include_directories(out/lib) in the outer most CMakeLists.txt
Edit #2
On Linux this error occures.
JNF_NEAT/Core/Sources/body.h. You cannot include it via#include <JNF_NEAT/body.h>. - Tsyvarev