I am trying to compile a project like below.
myproject
|CMakeLists.txt
|-src
| |main.cpp
| |subSrc1
| | |*.cpp
| | |*.h
| |subSrc2
| | |*.cpp
| | |*.hpp
I want to compile project with all *.cpp and *.h. so I made CMakeLists.txt by referring to the last comment of the url below. CMake with include and source paths - basic setup
> cmake_minimum_required (VERSION 3.8 FATAL_ERROR)
> project ("myproject")
> include_directories ("${PROJECT_SOURCE_DIR}")
> include_directories (
> ${PROJECT_SOURCE_DIR}/src
> ${PROJECT_SOURCE_DIR}/src/exec/
> ${PROJECT_SOURCE_DIR}/src/host/
> )
>
> file(GLOB all_SRCS
> "${PROJECT_SOURCE_DIR}/*.cpp"
> "${PROJECT_SOURCE_DIR}/src/*.cpp"
> "${PROJECT_SOURCE_DIR}/src/exec/*.cpp"
> "${PROJECT_SOURCE_DIR}/src/exec/*.h"
> "${PROJECT_SOURCE_DIR}/src/host/*.cpp"
> )
>
> #add_executable (myproject "myproject/src/main.cpp")
> add_executable (myproject ${all_SRCS})
but error says "NO SOURCES GIVEN TO TARGET". I think add_executable() needs main.cpp but if I do that, there is no way to tell CMakelist the locations of other sources( .cpp and .h files). Can I get some advise?