I am trying to build a simple CMake project but I'm having problems understanding CMake or at least the error I get.
The project i made is divided in a couple directories. The main one has this cmake:
cmake_minimum_required(VERSION 3.7.2)
project(Raytracer)
set(CMAKE_CXX_STANDARD 14)
add_subdirectory(src)
set(COMMON_INCLUDES ${PROJECT_SOURCE_DIR}/inc)
From there my project splits in 2 folders src and inc. and in src i have the following cmake with the idea to global all subfolders:
FILE(GLOB sub-dirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
FOREACH(dir ${sub-dirs})
IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
ADD_SUBDIRECTORY(${dir})
ENDIF()
ENDFOREACH()
add_executable(raytracer main.cpp)
I also add the executable there which is in this main src folder. From there on i want to be able to make sub folders adding with their own Cmake files and linking those files to my executable. I have the following cmake:
set(OBJECTS
asdf.cpp
)
add_library(obj_files ${OBJECTS} ${COMMON_FILES})
target_link_libraries(raytracer obj_files)
but when I try to build I get the following error:
Cannot specify link libraries for target "raytracer" which is not built by this project.