I need to compile one executable including all the source files inside the client
and the common
directories
\root
\client
*.cpp
*.h
CMakeLists.txt
\common
*.cpp
*.h
Here is my current CMakeLists.txt
cmake_minimum_required(VERSION 3.1.0)
project(Client)
set(common_dir ${PROJECT_SOURCE_DIR}/common)
include_directories(${common_dir})
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
#set(CMAKE_BUILD_TYPE RELEASE)
if (CMAKE_BUILD_TYPE STREQUAL "RELEASE")
add_definitions(-DQT_NO_DEBUG_OUTPUT)
endif (CMAKE_BUILD_TYPE STREQUAL "RELEASE")
if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
IF(WIN32)
SET(OS_SPECIFIC_LIBS netapi32 wsock32)
ENDIF(WIN32)
find_package(Qt5 COMPONENTS Core REQUIRED)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt5 COMPONENTS Gui REQUIRED)
find_package(Qt5 COMPONENTS Network REQUIRED)
#find_package(Qt5 COMPONENTS Sql REQUIRED)
find_package(Qt5 COMPONENTS Svg REQUIRED)
find_package(Qt5 COMPONENTS PrintSupport REQUIRED)
find_package(Qt5WebSockets REQUIRED)
file(GLOB client_src "*.h" "*.cpp" "Resources.qrc")
file(GLOB common_src "${common_dir}/*.h" "${common_dir}/*.cpp")
add_library(common_src)
add_executable(Client ${common_src} ${client_src})
target_link_libraries(Client ${common_dir} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Network Qt5::Svg Qt5::PrintSupport Qt5::WebSockets ${OS_SPECIFIC_LIBS})
But I'm getting this error:
mingw32-make.exe[3]: *** No rule to make target '../common', needed by 'Client.exe'. Stop.
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:126: CMakeFiles/Client.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:133: CMakeFiles/Client.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:150: Client] Error 2