I just would like to create my CMakeLists.txt like this, but the CMake guide is not that user friendly for beginners, I have already researched too much, do not downvote, please.
I have seen some solutions including in the add_executable() every source file manually, but I would like to make it more generic. Also, I would not like to use the file(GLOB SOURCES *.cpp *.h).
By the way, I am just attempting to create a Unix Makefile with the command
cmake -G 'Unix Makefiles'.. How can I do this?
CMakeLists.txt build/ ... project/ CMakeLists.txt Inc/ CMakeLists.txt *.h Src/ CMakeLists.txt main.cpp *.cpp I have so far for the main directory/CMakeLists.txt
cmake_minimum_required(VERSION 3.17) project(my_project) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a") add_subdirectory(project) for the project/CMakeLists.txt
add_subdirectory(Inc) add_subdirectory(Src) add_executable(exec ${Sources}) target_link_libraries(exec ${Headers}) For the Inc/CMakeLists.txt
add_library( Headers H1.h H2.h ... Hn.h ) and for the Src/CMakeLists.txt
set(Sources main.cpp Src1.cpp Src2.cpp ... Srcn.cpp ) As it is so far, it throws the following error
-- Version: 7.0.3 -- Build type: -- CXX_STANDARD: 11 -- Required features: cxx_variadic_templates -- Configuring done CMake Error: Cannot determine link language for target "exec". CMake Error: CMake can not determine linker language for target: exec CMake Error: Cannot determine link language for target "Headers". CMake Error: CMake can not determine linker language for target: Headers -- Generating done CMake Generate step failed. Build files cannot be regenerated correctly.
SrcandIncbelong to the same project? Why would you create so many CMakeLists?but I would like to make it more generic. Also, I would not like to use theSo what would you want to use instead and how do you want to make it "generic"?