D
D
Dolarun2022-02-14 07:46:35
CMake
Dolarun, 2022-02-14 07:46:35

Why can't CMake find the sources?

Project structure:
6209dd4bb047c158599015.png
CMakeLists.txt

cmake_minimum_required(VERSION 3.2)

project(2DPrimitive CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#add_subdirectory(tests/googletest)

add_subdirectory(source)

/source/CMakeLists.txt
cmake_minimum_required(VERSION 3.2)

project(2DPrimitive)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 1)

set(SOURCES 
Point.cpp 
Window.cpp)

set(HEADERS 
Point.hpp 
Window.hpp)

set(EXTERN_LIBS
ExternalDependencies/lib/libglad.a
ExternalDependencies/lib/libglfw3.a)

add_library(2DPrimitive STATIC $(SOURCES) $(HEADERS))

target_link_libraries(2DPrimitive ${EXTERN_LIBS})

set_target_properties(2DPrimitive PROPERTIES
                      OUTPUT_NAME 2DPrimitive
                      VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
                      SOVERSION ${PROJECT_VERSION_MAJOR}
                      POSITION_INDEPENDENT_CODE ON
                      FOLDER "../lib/")

Problem when generating makefile-a:
CMake Error at source/CMakeLists.txt:23 (add_library):
  Cannot find source file:

    $(SOURCES)

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc


CMake Error at source/CMakeLists.txt:23 (add_library):
  No SOURCES given to target: 2DPrimitive

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergio, 2022-02-14
@Dolarun

Because you have parentheses in $(SOURCES) instead of curly brackets - ${SOURCES} - and variable value substitution does not occur

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question