I can not start my cmake project. He should create a library (Core), and then add this library to a new shared library. The problem is that the resulting library does not seem to reference the executable correctly.
fatal error: JNF_NEAT/body.h: No such file or directory
I have a CMake project that 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 / kernel /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)
All source code is available here .
Edit # 1
I tried to install target_include_directories(XOR_EXAMPLE BEFORE PUBLIC ../../out/lib)beforetarget_link_libraries
I also tried installing include_directories(out/lib)in the majority of external CMakeLists.txt
Edit # 2
On Linux, this error .