CMake Linking Static Library and Glib Errors - c++

I have a pretty novice understanding of how Cmake works. I am have a project that includes a static library that in turn relies on glib. I am missing something that is causing a lot of undefined references to glib features like those below. I am working in Linux Ubuntu and have Cmake 3.5
../Gobbledegook/src/libggk.a(libggk_a-Gobbledegook.o): In function `ggkWait':
/home/ubuntu/visionpro-device-xray/src/user_device_interface/Gobbledegook/src/Gobbledegook.cpp:384: undefined reference to `g_set_print_handler'
/home/ubuntu/visionpro-device-xray/src/user_device_interface/Gobbledegook/src/Gobbledegook.cpp:385: undefined reference to `g_set_printerr_handler'
/home/ubuntu/visionpro-device-xray/src/user_device_interface/Gobbledegook/src/Gobbledegook.cpp:386: undefined reference to `g_log_set_default_handler'
Here is my Cmake file where I tried just building the library myself - without linking the static library. The library I am trying to use/include is https://github.com/nettlep/gobbledegook.
cmake_minimum_required(VERSION 3.2.2)
project(TestBLE)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -I/usr/include/glib-2.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/lib/aarch64-linux-gnu/glib-2.0/include")
find_package(PkgConfig REQUIRED)
pkg_search_module(GLIB REQUIRED glib-2.0)
include_directories(${GLIB_INCLUDE_DIRS})
link_directories(${GLIB_LIBRARY_DIRS})
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# Gets all the header/source files in current directory
file(GLOB SOURCES "*.cpp")
file(GLOB HEADERS "*.h")
file(GLOB GGK_SOURCES "Gobbledegook/src/*.cpp")
file(GLOB GGK_HEADERS "Gobbledegook/src/*.h")
add_executable(
${PROJECT_NAME}
${SOURCES}
${HEADERS}
${CMAKE_SOURCE_DIR}/Gobbledegook/include/Gobbledegook.h
${GGK_SOURCES}
${GGK_HEADERS}
)
target_link_libraries(
${PROJECT_NAME}
${GLIB_LIBRARIES}
Threads::Threads
)
Here is my CMake file trying to link the static library libggk.a built with the ./configure && make inside of the Gobbledegook library.
cmake_minimum_required(VERSION 3.2.2)
project(TestBLE)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -I/usr/include/glib-2.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/lib/aarch64-linux-gnu/glib-2.0/include")
find_package(PkgConfig REQUIRED)
pkg_search_module(GLIB REQUIRED glib-2.0)
include_directories(${GLIB_INCLUDE_DIRS})
link_directories(${GLIB_LIBRARY_DIRS})
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# Gets all the header/source files in current directory
file(GLOB SOURCES "*.cpp")
file(GLOB HEADERS "*.h")
add_executable(
${PROJECT_NAME}
${SOURCES}
${HEADERS}
${CMAKE_SOURCE_DIR}/Gobbledegook/include/Gobbledegook.h
)
target_link_libraries(
${PROJECT_NAME}
${GLIB_LIBRARIES}
Threads::Threads
${CMAKE_SOURCE_DIR}/Gobbledegook/src/libggk.a
)
I keep the undefined references in either case. Appreciate the help guys, I've been scouring the forums for a hint or an explanation.
EDIT:
here is my directory setup
project
|---------CMakeLists.txt
|---------build
|---------bluetest.cpp
|---------Gobbledegook
| |-----------include
| | |------Gobbldegook.h
| |-----------src
| | |------${all_the_source/header_files}
| | |------libggk.a
EDIT 2:
Modified Cmake to show prints
cmake_minimum_required(VERSION 3.2.2)
project(TestBLE)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB REQUIRED glib-2.0)
include_directories(Gobbledegook/include)
include_directories(${GLIB_INCLUDE_DIRS})
link_directories(${GLIB_LIBRARIES_DIRS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GLIB_CFLAGS}")
message(WARNING "GLIB_LIBRARIES: ${GLIB_LIBRARIES}")
message(WARNING "GLIB_LIBRARY_DIRS: ${GLIB_LIBRARY_DIRS}")
message(WARNING "GLIB_LDFLAGS: ${GLIB_LDFLAGS}")
message(WARNING "GLIB_LDFLAGS_OTHER: ${GLIB_LDFLAGS_OTHER}")
message(WARNING "GLIB_INCLUDE_DIRS: ${GLIB_INCLUDE_DIRS}")
message(WARNING "GLIB_CFLAGS: ${GLIB_CFLAGS}")
message(WARNING "GLIB_CFLAGS_OTHER: ${GLIB_CFLAGS_OTHER}")
pkg_check_modules(DBUS REQUIRED dbus-1)
include_directories(${DBUS_INCLUDE_DIRS})
link_directories(${DBUS_LIBRARIES_DIRS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DBUS_CFLAGS}")
message(WARNING "DBUS_LIBRARIES: ${DBUS_LIBRARIES}")
message(WARNING "DBUS_LIBRARY_DIRS: ${DBUS_LIBRARY_DIRS}")
message(WARNING "DBUS_LDFLAGS: ${DBUS_LDFLAGS}")
message(WARNING "DBUS_LDFLAGS_OTHER: ${DBUS_LDFLAGS_OTHER}")
message(WARNING "DBUS_INCLUDE_DIRS: ${DBUS_INCLUDE_DIRS}")
message(WARNING "DBUS_CFLAGS: ${DBUS_CFLAGS}")
message(WARNING "DBUS_CFLAGS_OTHER: ${DBUS_CFLAGS_OTHER}")
pkg_check_modules(DBUS_GLIB REQUIRED dbus-glib-1)
include_directories(${DBUS_GLIB_INCLUDE_DIRS})
link_directories(${DBUS_GLIB_LIBRARIES_DIRS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DBUS_GLIB_CFLAGS}")
message(WARNING "DBUS_GLIB_LIBRARIES: ${DBUS_GLIB_LIBRARIES}")
message(WARNING "DBUS_GLIB_LIBRARY_DIRS: ${DBUS_GLIB_LIBRARY_DIRS}")
message(WARNING "DBUS_GLIB_LDFLAGS: ${DBUS_GLIB_LDFLAGS}")
message(WARNING "DBUS_GLIB_LDFLAGS_OTHER: ${DBUS_GLIB_LDFLAGS_OTHER}")
message(WARNING "DBUS_GLIB_INCLUDE_DIRS: ${DBUS_GLIB_INCLUDE_DIRS}")
message(WARNING "DBUS_GLIB_CFLAGS: ${DBUS_GLIB_CFLAGS}")
message(WARNING "DBUS_GLIB_CFLAGS_OTHER: ${DBUS_GLIB_CFLAGS_OTHER}")
message(WARNING "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
set(THREADS_PREFER_PTHREAD_FLAG ON)
FIND_PACKAGE(Threads REQUIRED)
# Gets all the header/source files in current directory
file(GLOB SOURCES "*.cpp")
file(GLOB HEADERS "*.h")
file(GLOB GGK_SOURCES "Gobbledegook/src/*.cpp")
file(GLOB GGK_HEADERS "Gobbledegook/src/*.h")
add_executable(
${PROJECT_NAME}
${SOURCES}
${HEADERS}
#${CMAKE_SOURCE_DIR}/Gobbledegook/include/Gobbledegook.h
${GGK_SOURCES}
${GGK_HEADERS}
)
target_include_directories(
${PROJECT_NAME}
PUBLIC ${GLIB_INCLUDE_DIRS}
PUBLIC ${DBUS_INCLUDE_DIRS}
PUBLIC ${DBUS_GLIB_INCLUDE_DIRS}
)
target_link_libraries(
${PROJECT_NAME}
PUBLIC ${GLIB_LIBRARIES}
PUBLIC ${DBUS_LIBRARIES}
PUBLIC ${DBUS_GLIB_LIBRARIES}
Threads::Threads
)
Output from the modified CMake file
ubuntu#tegra-ubuntu:~/visionpro-device-xray/src/user_device_interface/build$ sudo cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Checking for module 'glib-2.0'
-- Found glib-2.0, version 2.48.2
CMake Warning at CMakeLists.txt:15 (message):
GLIB_LIBRARIES: glib-2.0
CMake Warning at CMakeLists.txt:16 (message):
GLIB_LIBRARY_DIRS:
CMake Warning at CMakeLists.txt:17 (message):
GLIB_LDFLAGS: -lglib-2.0
CMake Warning at CMakeLists.txt:18 (message):
GLIB_LDFLAGS_OTHER:
CMake Warning at CMakeLists.txt:19 (message):
GLIB_INCLUDE_DIRS:
/usr/include/glib-2.0;/usr/lib/aarch64-linux-gnu/glib-2.0/include
CMake Warning at CMakeLists.txt:20 (message):
GLIB_CFLAGS:
-I/usr/include/glib-2.0;-I/usr/lib/aarch64-linux-gnu/glib-2.0/include
CMake Warning at CMakeLists.txt:21 (message):
GLIB_CFLAGS_OTHER:
-- Checking for module 'dbus-1'
-- Found dbus-1, version 1.10.6
CMake Warning at CMakeLists.txt:28 (message):
DBUS_LIBRARIES: dbus-1
CMake Warning at CMakeLists.txt:29 (message):
DBUS_LIBRARY_DIRS:
CMake Warning at CMakeLists.txt:30 (message):
DBUS_LDFLAGS: -ldbus-1
CMake Warning at CMakeLists.txt:31 (message):
DBUS_LDFLAGS_OTHER:
CMake Warning at CMakeLists.txt:32 (message):
DBUS_INCLUDE_DIRS:
/usr/include/dbus-1.0;/usr/lib/aarch64-linux-gnu/dbus-1.0/include
CMake Warning at CMakeLists.txt:33 (message):
DBUS_CFLAGS:
-I/usr/include/dbus-1.0;-I/usr/lib/aarch64-linux-gnu/dbus-1.0/include
CMake Warning at CMakeLists.txt:34 (message):
DBUS_CFLAGS_OTHER:
-- Checking for module 'dbus-glib-1'
-- Found dbus-glib-1, version 0.106
CMake Warning at CMakeLists.txt:41 (message):
DBUS_GLIB_LIBRARIES: dbus-glib-1;dbus-1;gobject-2.0;glib-2.0
CMake Warning at CMakeLists.txt:42 (message):
DBUS_GLIB_LIBRARY_DIRS:
CMake Warning at CMakeLists.txt:43 (message):
DBUS_GLIB_LDFLAGS: -ldbus-glib-1;-ldbus-1;-lgobject-2.0;-lglib-2.0
CMake Warning at CMakeLists.txt:44 (message):
DBUS_GLIB_LDFLAGS_OTHER:
CMake Warning at CMakeLists.txt:45 (message):
DBUS_GLIB_INCLUDE_DIRS:
/usr/include/dbus-1.0;/usr/lib/aarch64-linux-gnu/dbus-1.0/include;/usr/include/glib-2.0;/usr/lib/aarch64-linux-gnu/glib-2.0/include
CMake Warning at CMakeLists.txt:46 (message):
DBUS_GLIB_CFLAGS:
-I/usr/include/dbus-1.0;-I/usr/lib/aarch64-linux-gnu/dbus-1.0/include;-I/usr/include/glib-2.0;-I/usr/lib/aarch64-linux-gnu/glib-2.0/include
CMake Warning at CMakeLists.txt:47 (message):
DBUS_GLIB_CFLAGS_OTHER:
CMake Warning at CMakeLists.txt:49 (message):
CMAKE_CXX_FLAGS: -std=c++11
-I/usr/include/glib-2.0;-I/usr/lib/aarch64-linux-gnu/glib-2.0/include
-I/usr/include/dbus-1.0;-I/usr/lib/aarch64-linux-gnu/dbus-1.0/include
-I/usr/include/dbus-1.0;-I/usr/lib/aarch64-linux-gnu/dbus-1.0/include;-I/usr/include/glib-2.0;-I/usr/lib/aarch64-linux-gnu/glib-2.0/include
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/visionpro-device-xray/src/user_device_interface/build

I found the issue and it has to do with needing to include gtk+-2.0. I don't know why gtk+-2.0 is used in the library I am linking because its not a graphical program. The CmakeLists.txt should look like this below.
cmake_minimum_required(VERSION 3.2.2)
project(TestBLE)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") #All warning
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") #Extra warning flags
#####################################################################
# Including Packages
#####################################################################
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB REQUIRED glib-2.0)
include_directories(${GLIB_INCLUDE_DIRS})
pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
include_directories(${GTK2_INCLUDE_DIRS})
set(THREADS_PREFER_PTHREAD_FLAG ON)
FIND_PACKAGE(Threads REQUIRED)
#####################################################################
# Files to add to the executable
#####################################################################
file(GLOB SOURCES "*.cpp")
file(GLOB HEADERS "*.h")
file(GLOB GGK_SOURCES "Gobbledegook/src/*.cpp")
file(GLOB GGK_HEADERS "Gobbledegook/src/*.h")
add_executable(
${PROJECT_NAME}
${SOURCES}
${HEADERS}
#${CMAKE_SOURCE_DIR}/Gobbledegook/include/Gobbledegook.h
${GGK_SOURCES}
${GGK_HEADERS}
)
target_include_directories(
${PROJECT_NAME}
PUBLIC ${GLIB_INCLUDE_DIRS}
)
target_link_libraries(
${PROJECT_NAME}
PUBLIC ${GLIB_LIBRARIES}
PUBLIC ${GTK2_LIBRARIES}
Threads::Threads
)
Hopefully this helps someone else who is trying to incorporate the Gobbledegook Library into their build.

Related

Compile Cpp file which is using VTK library with CMake

I want to compile cpp source code in which VTK, Eigen, PETSc and dealII libraries are included. source files are located in src directory and header files in ìnclude directory.
The CMakeLists.txtfile is as follows:
cmake_minimum_required(VERSION 3.20.3)
project(ddm_library)
set (CMAKE_CXX_FLAGS "-Wsign-compare -Wno-unused-variable -Wno-unused-parameter -Wdeprecated-copy")
set(VTK_DIR /home/mehdi/myFolder/programming/lib/VTK-9.0.3/build)
# PkgConfig
find_package(PkgConfig)
# PETSc
if (PKG_CONFIG_FOUND)
pkg_check_modules(PETSC PETSc)
endif()
# include PETSC
if (PETSC_FOUND)
list(APPEND COMPILE_OPTIONS ${PETSC_CFLAGS})
include_directories(${PETSC_INCLUDE_DIRS})
set(LINK_FLAGS "${LINK_FLAGS} ${PETSC_LDFLAGS}")
list(APPEND LIBRARIES ${PETSC_LINK_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS ${PETSC_CFLAGS})
set(CMAKE_REQUIRED_INCLUDES "${PETSC_INCLUDE_DIRS}")
endif()
# include Eigen
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
# VTK library
find_package(VTK COMPONENTS
vtkCommonColor
vtkCommonCore
vtkCommonDataModel
vtkInteractionStyle
vtkRenderingContextOpenGL2
vtkRenderingCore
vtkRenderingFreeType
vtkRenderingGL2PSOpenGL2
vtkRenderingOpenGL2
vtkCommonCore
vtkCommonDataModel
vtkIOXML
QUIET
)
if (NOT VTK_FOUND)
message("Skipping StructuredGrid: ${VTK_NOT_FOUND_MESSAGE}")
return ()
endif()
message (STATUS "VTK_VERSION: ${VTK_VERSION}")
# dealII
FIND_PACKAGE(deal.II 9.3.0 QUIET
HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
)
IF(NOT ${deal.II_FOUND})
MESSAGE(FATAL_ERROR "\n"
"*** Could not locate a (sufficiently recent) version of deal.II. ***\n\n"
"You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n"
"or set an environment variable \"DEAL_II_DIR\" that contains this path."
)
ENDIF()
DEAL_II_INITIALIZE_CACHED_VARIABLES()
if (VTK_VERSION VERSION_LESS "8.90.0")
# old system
INCLUDE_DIRECTORIES(include ${VTK_USE_FILE} ${VTK_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR})
file (GLOB LIB "src/*.cc")
ADD_LIBRARY(lib ${LIB})
vtk_module_autoinit(
TARGETS lib
MODULES ${VTK_LIBRARIES}
)
DEAL_II_SETUP_TARGET(lib)
add_executable(${PROJECT_NAME} MACOSX_BUNDLE "test/main.cc")
DEAL_II_SETUP_TARGET(${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} PRIVATE lib Eigen3::Eigen ${VTK_LIBRARIES})
else ()
# include all components
INCLUDE_DIRECTORIES(include ${VTK_USE_FILE} ${VTK_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR})
file (GLOB LIB "src/*.cc")
ADD_LIBRARY(lib ${LIB})
vtk_module_autoinit(
TARGETS lib
MODULES ${VTK_LIBRARIES}
)
DEAL_II_SETUP_TARGET(lib)
add_executable(${PROJECT_NAME} MACOSX_BUNDLE "test/main.cc")
DEAL_II_SETUP_TARGET(${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} PRIVATE lib Eigen3::Eigen ${VTK_LIBRARIES})
# vtk_module_autoinit is needed
vtk_module_autoinit(
TARGETS ${PROJECT_NAME}
MODULES ${VTK_LIBRARIES}
)
endif ()
running cmd like
$ cmake -DCMAKE_BUILD_TYPE=Debug ..
-- The C compiler identification is GNU 11.1.0
-- The CXX compiler identification is GNU 11.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.7.3")
-- Checking for module 'PETSc'
-- Found PETSc, version 3.15.0
-- VTK_VERSION: 9.0.3
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mehdi/myFolder/programming/domain_decomposition/build
which finds all the packages. Then running the cmd
$ make
cc1plus: warning: /home/mehdi/myFolder/programming/lib/VTK-9.0.3/build/lib/cmake/vtk-9.0/vtk-use-file-deprecated.cmake: not a directory
In file included from /home/mehdi/myFolder/programming/domain_decomposition/src/post_processing.cc:2:
/home/mehdi/myFolder/programming/domain_decomposition/include/post_processing.hpp:14:10: fatal error: vtkActor.h: No such file or directory
14 | #include <vtkActor.h>
| ^~~~~~~~~~~~
I can not understand why I got such a error.
I modified the CMakeLists.txtby removing PRIVATEfrom target_link_librariesand add target_link_librariesfor lib, and the problem solved. The new CMakeLists.txt is look like this:
cmake_minimum_required(VERSION 3.20.3)
project(ddm_library)
set (CMAKE_CXX_FLAGS "-Wsign-compare -Wno-unused-variable -Wno-unused-parameter -Wdeprecated-copy")
set(VTK_DIR /home/mehdi/myFolder/programming/lib/VTK-9.0.3/build)
# PkgConfig
find_package(PkgConfig)
# PETSc
if (PKG_CONFIG_FOUND)
pkg_check_modules(PETSC PETSc)
endif()
# include PETSC
if (PETSC_FOUND)
list(APPEND COMPILE_OPTIONS ${PETSC_CFLAGS})
include_directories(${PETSC_INCLUDE_DIRS})
set(LINK_FLAGS "${LINK_FLAGS} ${PETSC_LDFLAGS}")
list(APPEND LIBRARIES ${PETSC_LINK_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS ${PETSC_CFLAGS})
set(CMAKE_REQUIRED_INCLUDES "${PETSC_INCLUDE_DIRS}")
endif()
# include Eigen
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
# VTK library
find_package(VTK COMPONENTS
vtkCommonColor
vtkCommonCore
vtkCommonDataModel
vtkInteractionStyle
vtkRenderingContextOpenGL2
vtkRenderingCore
vtkRenderingFreeType
vtkRenderingGL2PSOpenGL2
vtkRenderingOpenGL2
vtkCommonCore
vtkCommonDataModel
vtkIOXML
QUIET
)
if (NOT VTK_FOUND)
message("Skipping StructuredGrid: ${VTK_NOT_FOUND_MESSAGE}")
return ()
endif()
message (STATUS "VTK_VERSION: ${VTK_VERSION}")
# dealII
FIND_PACKAGE(deal.II 9.3.0 QUIET
HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
)
IF(NOT ${deal.II_FOUND})
MESSAGE(FATAL_ERROR "\n"
"*** Could not locate a (sufficiently recent) version of deal.II. ***\n\n"
"You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n"
"or set an environment variable \"DEAL_II_DIR\" that contains this path."
)
ENDIF()
DEAL_II_INITIALIZE_CACHED_VARIABLES()
#INCLUDE_DIRECTORIES(SYSTEM ${VTK_INCLUDE_DIRS})
if (VTK_VERSION VERSION_LESS "8.90.0")
# old system
INCLUDE_DIRECTORIES(include ${VTK_USE_FILE} ${VTK_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR})
FILE (GLOB LIB "src/*.cc")
ADD_LIBRARY(lib OBJECT ${LIB})
vtk_module_autoinit(
TARGETS lib
MODULES ${VTK_LIBRARIES}
)
TARGET_LINK_LIBRARIES(lib Eigen3::Eigen ${VTK_LIBRARIES})
DEAL_II_SETUP_TARGET(lib)
add_executable(${PROJECT_NAME} MACOSX_BUNDLE "test/main.cc")
DEAL_II_SETUP_TARGET(${PROJECT_NAME})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} lib Eigen3::Eigen ${VTK_LIBRARIES})
else ()
# include all components
INCLUDE_DIRECTORIES(include ${VTK_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR})
FILE (GLOB LIB "src/*.cc")
ADD_LIBRARY(lib OBJECT ${LIB})
vtk_module_autoinit(
TARGETS lib
MODULES ${VTK_LIBRARIES}
)
TARGET_LINK_LIBRARIES(lib Eigen3::Eigen ${VTK_LIBRARIES})
DEAL_II_SETUP_TARGET(lib)
add_executable(${PROJECT_NAME} MACOSX_BUNDLE "test/main.cc")
DEAL_II_SETUP_TARGET(${PROJECT_NAME})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} lib Eigen3::Eigen ${VTK_LIBRARIES})
# vtk_module_autoinit is needed
vtk_module_autoinit(
TARGETS ${PROJECT_NAME}
MODULES ${VTK_LIBRARIES}
)
endif ()

Cmake: pkg_check_modules error: Package '...', required by 'virtual:world', not found

I am trying to build a c++ project with Netbeans in Windows but during the pre-built process an error relating to the CMakeLists I used comes out. Here is the error output:
cd 'E:\Yifan\Hiwi-FSD\FluCo1\Sourcecode\branch_HighLevelUmstrukturierung\High-Level\FCU-Interface\build-dev'
C:/msys64/mingw64/bin/cmake.exe -G Unix Makefiles -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=E:/Yifan/Hiwi-FSD/FluCo1/Sourcecode/branch_HighLevelUmstrukturierung/High-Level/FCU-Interface/nbproject/private/tools/localhost/MinGW_1/gcc.exe -DCMAKE_CXX_COMPILER=E:/Yifan/Hiwi-FSD/FluCo1/Sourcecode/branch_HighLevelUmstrukturierung/High-Level/FCU-Interface/nbproject/private/tools/localhost/MinGW_1/g++.exe -DCMAKE_C_FLAGS_DEBUG=-g3 -gdwarf-2 -DCMAKE_CXX_FLAGS_DEBUG=-g3 -gdwarf-2 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DPROJECT_SUFFIX=-dev -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=TRUE -DCMAKE_PREFIX_PATH=E:\Yifan\Hiwi-FSD\FluCo1\Libraries\fsd-libs\trunk\build-dev\install ..
-- SVN Revision Number is
-- FCU-Interface-dev PROJECT_SOURCE_DIR = E:/Yifan/Hiwi-FSD/FluCo1/Sourcecode/branch_HighLevelUmstrukturierung/High-Level/FCU-Interface
-- FCU-Interface-dev Build directory = E:/Yifan/Hiwi-FSD/FluCo1/Sourcecode/branch_HighLevelUmstrukturierung/High-Level/FCU-Interface/build-dev
-- Checking for module 'fsd-io-dev'
-- Package 'fsd-io-dev', required by 'virtual:world', not found
CMake Error at C:/msys64/mingw64/share/cmake-3.20/Modules/FindPkgConfig.cmake:561 (message):
A required package was not found
Call Stack (most recent call first):
C:/msys64/mingw64/share/cmake-3.20/Modules/FindPkgConfig.cmake:783 (_pkg_check_modules_internal)
CMakeLists.txt:17 (pkg_check_modules)
-- Configuring incomplete, errors occurred!
See also "E:/Yifan/Hiwi-FSD/FluCo1/Sourcecode/branch_HighLevelUmstrukturierung/High-Level/FCU-Interface/build-dev/CMakeFiles/CMakeOutput.log".
PRE-BUILD FAILED (exit value 1, total time: 5s)
And the CMakelists file is shown below:
cmake_minimum_required(VERSION 3.12)
SET(FSD_LIB_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../Libraries)
include("${FSD_LIB_DIR}/CMakeSuffixBase.cmake")
project("FCU-Interface${PROJECT_SUFFIX}" VERSION 0.1)
SET(ENV{PKG_CONFIG_PATH} ${FSD_LIB_DIR}/fsd-libs/trunk/build${PROJECT_SUFFIX}/install/lib/pkgconfig)
include("${FSD_LIB_DIR}/CMakeBase.cmake")
include(FindPkgConfig)
Subversion_GET_REVISION(${CMAKE_SOURCE_DIR} SVN_REV)
message(STATUS "SVN Revision Number is ${SVN_REV}")
message(STATUS "${PROJECT_NAME} PROJECT_SOURCE_DIR = ${PROJECT_SOURCE_DIR}")
message(STATUS "${PROJECT_NAME} Build directory = ${CMAKE_BINARY_DIR}")
find_package(PkgConfig REQUIRED)
pkg_check_modules(FSD_IO REQUIRED IMPORTED_TARGET fsd-io${PROJECT_SUFFIX})
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
file(GLOB_RECURSE SOURCE_FILES "src/*.cpp")
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION "${PROJECT_VERSION}+${SVN_REV}"
)
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/>
)
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../Framework_Seitz>
)
target_link_libraries(${PROJECT_NAME} PRIVATE
Threads::Threads
PkgConfig::FSD_IO)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
The PROJECT_SUFFIX is -dev. I reckon that the problem is, the file "fsd-io-dev.pc" cannot be found. But I already have it under the directory "E:\Yifan\Hiwi-FSD\FluCo1\Libraries\fsd-libs\trunk\build-dev\install\lib\pkgconfig". What should I do to let it be found? Thanks in advance!!!

How can I use cmake's find_packge(OpenCV) on gitlab

I am using cmake to compile a c++ and OpenCV project. and I want to run my tests on Gitlab but got some errors. My question is: How can I use find_package(OpenCV REQUIRED) in CMakeLists.txt on gitlab? this is my CMakeLists.txt: (by the way, it works correct locally on my Linux machine .)
# cmake minimum requiredments
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
# project name
project(imageEnhancer LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF) # disable compiler specific extensions
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Catch2 QUIET)
if (NOT Catch2_FOUND)
message("Catch2 not found")
include(FetchContent)
FetchContent_Declare(
catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.11.0
)
FetchContent_MakeAvailable(catch2)
list(APPEND CMAKE_MODULE_PATH "${catch2_SOURCE_DIR}/contrib")
endif()
# search for OpenMP
find_package(OpenMP REQUIRED)
# search for OpenCV
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
# add a library to the project using the specified source files
add_library(opencv STATIC include/opencvtest.h src/opencvtest.cpp)
# PUBLIC -> targets that link to this target get that include directory
target_include_directories(opencv PUBLIC include PRIVATE src)
# link to the imported target provided by the FindOpenMP moudule
target_link_libraries(opencv PUBLIC OpenMP::OpenMP_CXX)
# Create executable with name imageEnhancer
add_executable(imageEnhancer main.cpp)
# linke to the imported target provided by the FindOpenMP module
target_link_libraries(imageEnhancer PUBLIC OpenMP::OpenMP_CXX ${OpenCV_LIBS})
but I got the following error:
$ cd project
$ mkdir -p build
$ cd build
$ cmake ..
-- The CXX compiler identification is GNU 10.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Catch2 not found
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
CMake Error at CMakeLists.txt:31 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/builds/davood_hadiannejad/algorithm-engineering-lab/project/build/CMakeFiles/CMakeOutput.log".
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
and I tried to solve it like, but it didn't work
if (NOT Catch2_FOUND)
message("Catch2 not found")
include(FetchContent)
FetchContent_Declare(
OpenCV
GIT_REPOSITORY https://github.com/opencv/opencv.git
)
FetchContent_MakeAvailable(OpenCV)
list(APPEND CMAKE_MODULE_PATH "${OpenCV_SOURCE_DIR}/contrib")
endif()
any suggestion? thanks in advance

Vcpkg Pango CMake build fails missing header file

I am trying to install Wt using vcpkg, and pango is one of the dependencies. However, I am having serious issues trying to make it build correctly. Here is what the terminal outputs:
Starting package 1/2: pango:x64-osx
Building package pango[core]:x64-osx...
-- Using cached /Users/jackhogan/Desktop/Code/Utilities/vcpkg/downloads/pango-1.40.11.tar.xz
-- Using source at /Users/jackhogan/Desktop/Code/Utilities/vcpkg/buildtrees/pango/src/1.40.11-f997ae867d
-- Configuring x64-osx-dbg
-- Configuring x64-osx-rel
-- Building x64-osx-dbg
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:136 (message):
Command failed: /Users/jackhogan/Desktop/Code/Utilities/vcpkg/downloads/tools/cmake-3.17.2-osx/cmake-3.17.2-Darwin-x86_64/CMake.app/Contents/bin/cmake --build . --config Debug --target install -- -v
Working Directory: /Users/jackhogan/Desktop/Code/Utilities/vcpkg/buildtrees/pango/x64-osx-dbg
See logs for more information:
/Users/jackhogan/Desktop/Code/Utilities/vcpkg/buildtrees/pango/install-x64-osx-dbg-out.log
Call Stack (most recent call first):
scripts/cmake/vcpkg_build_cmake.cmake:91 (vcpkg_execute_build_process)
scripts/cmake/vcpkg_install_cmake.cmake:24 (vcpkg_build_cmake)
ports/pango/portfile.cmake:25 (vcpkg_install_cmake)
scripts/ports.cmake:76 (include)
Error: Building package pango:x64-osx failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `.\vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
Package: pango:x64-osx
Vcpkg version: 2020.02.04-unknownhash
Additionally, attach any relevant sections from the log files above.
Here is the out file the terminal references:
-- The C compiler identification is AppleClang 11.0.3.11030032
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Link-time dependencies:
-- /Users/jackhogan/Desktop/Code/Utilities/vcpkg/installed/x64-osx/debug/lib/libintl.a
-- /Users/jackhogan/Desktop/Code/Utilities/vcpkg/installed/x64-osx/debug/lib/libglib-2.0.a
-- /Users/jackhogan/Desktop/Code/Utilities/vcpkg/installed/x64-osx/debug/lib/libgobject-2.0.a
-- /Users/jackhogan/Desktop/Code/Utilities/vcpkg/installed/x64-osx/debug/lib/libgmodule-2.0.a
-- /Users/jackhogan/Desktop/Code/Utilities/vcpkg/installed/x64-osx/debug/lib/libcairod.a
-- /Users/jackhogan/Desktop/Code/Utilities/vcpkg/installed/x64-osx/debug/lib/libcairo-gobjectd.a
-- /Users/jackhogan/Desktop/Code/Utilities/vcpkg/installed/x64-osx/debug/lib/libfreetyped.a
-- /Users/jackhogan/Desktop/Code/Utilities/vcpkg/installed/x64-osx/debug/lib/libfontconfig.a
-- /Users/jackhogan/Desktop/Code/Utilities/vcpkg/installed/x64-osx/debug/lib/libharfbuzz.a
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/jackhogan/Desktop/Code/Utilities/vcpkg/buildtrees/pango/x64-osx-dbg
Here is the CMakeLists.txt:
cmake_minimum_required(VERSION 3.0)
project(pango C)
set(PANGO_LIB_SUFFIX 1.0)
set(PANGO_DLL_SUFFIX 1)
set(GLIB_LIB_VERSION 2.0)
if(WIN32)
configure_file(./config.h.win32 ${CMAKE_CURRENT_BINARY_DIR}/config.h COPYONLY)
else()
configure_file(./config.h.unix ${CMAKE_CURRENT_BINARY_DIR}/config.h COPYONLY)
endif()
if (WIN32)
# Set utf-8 charset to avoid compile error C2001
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8")
endif()
add_definitions(-DHAVE_CONFIG_H)
include_directories(. ./pango ${CMAKE_CURRENT_BINARY_DIR})
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
# find libintl
find_path(LIBINTL_INCLUDE_DIR libintl.h)
find_library(LIBINTL_LIBRARY NAMES libintl intl)
endif()
# find glib
find_path(GLIB_INCLUDE_DIR glib.h)
find_library(GLIB_GLIB_LIBRARY glib-${GLIB_LIB_VERSION})
find_library(GLIB_GOBJECT_LIBRARY gobject-${GLIB_LIB_VERSION})
find_library(GLIB_GMODULE_LIBRARY gmodule-${GLIB_LIB_VERSION})
set(GLIB_LIBRARIES ${GLIB_GLIB_LIBRARY} ${GLIB_GOBJECT_LIBRARY} ${GLIB_GMODULE_LIBRARY})
# find cairo
find_path(CAIRO_INCLUDE_DIR cairo.h)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CAIRO_SUFFIX d)
endif()
find_library(CAIRO_LIBRARY
NAMES
cairo${CAIRO_SUFFIX}
cairo-static${CAIRO_SUFFIX})
find_library(CAIRO_GOBJECT_LIBRARY cairo-gobject${CAIRO_SUFFIX})
set(CAIRO_LIBRARIES ${CAIRO_LIBRARY} ${CAIRO_GOBJECT_LIBRARY})
# find fontconfig
find_path(FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h)
find_library(FONTCONFIG_LIBRARY fontconfig)
# find freetype
find_path(FREETYPE_INCLUDE_DIR ft2build.h)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(FT_SUFFIX d)
endif()
find_library(FREETYPE_LIBRARY freetype${FT_SUFFIX})
# find harfbuzz
find_path(HARFBUZZ_INCLUDE_DIR harfbuzz/hb.h)
find_library(HARFBUZZ_LIBRARY harfbuzz)
if (APPLE)
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
link_libraries(${COREFOUNDATION_LIBRARY})
endif()
set(FONT_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR} ${FONTCONFIG_INCLUDE_DIR} ${HARFBUZZ_INCLUDE_DIR}/harfbuzz)
set(FONT_LIBRARIES ${FREETYPE_LIBRARY} ${FONTCONFIG_LIBRARY} ${HARFBUZZ_LIBRARY})
macro(pango_add_module MODULE_NAME)
add_library(${MODULE_NAME} ${ARGN})
target_include_directories(${MODULE_NAME} PRIVATE ${GLIB_INCLUDE_DIR} ${LIBINTL_INCLUDE_DIR})
target_link_libraries(${MODULE_NAME} ${LIBINTL_LIBRARY} ${GLIB_LIBRARIES})
target_compile_definitions(${MODULE_NAME} PRIVATE
G_LOG_DOMAIN="Pango" PANGO_ENABLE_BACKEND PANGO_ENABLE_ENGINE
G_DISABLE_SINGLE_INCLUDES SYSCONFDIR="/dummy/etc" LIBDIR="/dummy/lib")
target_compile_definitions(${MODULE_NAME} PRIVATE HAVE_CAIRO_FREETYPE=1)
set_target_properties(${MODULE_NAME} PROPERTIES
DEFINE_SYMBOL PANGO_EXPORTS
OUTPUT_NAME ${MODULE_NAME}-${PANGO_DLL_SUFFIX}
ARCHIVE_OUTPUT_NAME ${MODULE_NAME}-${PANGO_LIB_SUFFIX})
install(TARGETS ${MODULE_NAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
endmacro()
pango_add_module(pango
pango/break-arabic.c
pango/break-indic.c
pango/mini-fribidi/fribidi.c
pango/mini-fribidi/fribidi_char_type.c
pango/mini-fribidi/fribidi_types.c
pango/break.c
pango/ellipsize.c
pango/fonts.c
pango/glyphstring.c
pango/modules.c
pango/pango-attributes.c
pango/pango-bidi-type.c
pango/pango-color.c
pango/pango-context.c
pango/pango-coverage.c
pango/pango-emoji.c
pango/pango-engine.c
pango/pango-fontmap.c
pango/pango-fontset.c
pango/pango-glyph-item.c
pango/pango-gravity.c
pango/pango-item.c
pango/pango-language.c
pango/pango-layout.c
pango/pango-markup.c
pango/pango-matrix.c
pango/pango-renderer.c
pango/pango-script.c
pango/pango-tabs.c
pango/pango-utils.c
pango/reorder-items.c
pango/shape.c
pango/pango-enum-types.c)
if(WIN32)
pango_add_module(pangowin32
pango/pangowin32.c
pango/pangowin32-fontcache.c
pango/pangowin32-fontmap.c
pango/pangowin32-shape.c)
target_link_libraries(pangowin32 usp10 pango gdi32)
endif()
pango_add_module(pangoft2
pango/pangofc-font.c
pango/pangofc-fontmap.c
pango/pangofc-decoder.c
pango/pangofc-shape.c
pango/pangoft2.c
pango/pangoft2-fontmap.c
pango/pangoft2-render.c
pango/pango-ot-buffer.c
pango/pango-ot-info.c
pango/pango-ot-ruleset.c
pango/pango-ot-tag.c)
target_link_libraries(pangoft2 pango ${FONT_LIBRARIES})
target_include_directories(pangoft2 PRIVATE ${FONT_INCLUDE_DIRS})
list(APPEND PANGO_CAIRO_SOURCES
pango/pangocairo-fcfont.c
pango/pangocairo-fcfontmap.c
pango/pangocairo-context.c
pango/pangocairo-font.c
pango/pangocairo-fontmap.c
pango/pangocairo-render.c)
if(WIN32)
list(APPEND PANGO_CAIRO_SOURCES
pango/pangocairo-win32font.c
pango/pangocairo-win32fontmap.c)
endif()
pango_add_module(pangocairo ${PANGO_CAIRO_SOURCES})
list(APPEND PANGO_CAIRO_LIBRARIES ${CAIRO_LIBRARIES} pango pangoft2 ${FONT_LIBRARIES})
if (WIN32)
list(APPEND PANGO_CAIRO_LIBRARIES pangowin32)
endif()
target_link_libraries(pangocairo ${PANGO_CAIRO_LIBRARIES})
target_include_directories(pangocairo PRIVATE ${CAIRO_INCLUDE_DIR} ${FONT_INCLUDE_DIRS})
if(NOT PANGO_SKIP_HEADERS)
install(FILES
pango/pango.h
pango/pango-attributes.h
pango/pango-bidi-type.h
pango/pango-break.h
pango/pango-context.h
pango/pango-coverage.h
pango/pango-engine.h
pango/pango-font.h
pango/pango-fontmap.h
pango/pango-fontset.h
pango/pango-glyph.h
pango/pango-glyph-item.h
pango/pango-gravity.h
pango/pango-item.h
pango/pango-language.h
pango/pango-layout.h
pango/pango-matrix.h
pango/pango-modules.h
pango/pango-renderer.h
pango/pango-script.h
pango/pango-tabs.h
pango/pango-types.h
pango/pango-utils.h
pango/pango-version-macros.h
pango/pangocairo.h
pango/pangowin32.h
pango/pango-features.h
pango/pango-enum-types.h
pango/pangofc-decoder.h
pango/pangofc-font.h
pango/pangofc-fontmap.h
pango/pango-ot.h
pango/pangoft2.h
DESTINATION include/pango)
endif()
message(STATUS "Link-time dependencies:")
message(STATUS " " ${LIBINTL_LIBRARY})
foreach(GL ${GLIB_LIBRARIES})
message(STATUS " " ${GL})
endforeach()
foreach(CL ${CAIRO_LIBRARIES})
message(STATUS " " ${CL})
endforeach()
foreach(FL ${FONT_LIBRARIES})
message(STATUS " " ${FL})
endforeach()
What could the problem be and how could I solve it? Vcpkg uses Clang but I also have GCC installed, so I could switch to it if necessary.
UPDATE
I ran some commands and found out that it couldn't find hb-glib.h. However, I already have glib and harfbuzz installed. I am even able to find the missing header file. What could be the cause of this issue?
Well, contrary to my expectations, just copying hb-glib.h to the pango source folder and building worked.

Cannot find source file error when running CMake

Error from Terminal:
ics45c#ics45c-2019fall : ~/projects/proj1 $ ./build app
-- Configuring done
CMake Error at CMakeLists.txt:49 (add_executable):
Cannot find source file:
/home/ics45c/projects/proj1/app/.#main.cpp
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
CMake Error: CMake can not determine linker language for target: a.out.gtest
CMake Error: Cannot determine link language for target "a.out.gtest".
CMake Error: CMake can not determine linker language for target: a.out.app
CMake Error: Cannot determine link language for target "a.out.app".
CMake Error: CMake can not determine linker language for target: a.out.exp
CMake Error: Cannot determine link language for target "a.out.exp".
-- Generating done
-- Build files have been written to: /home/ics45c/projects/proj1/out
I checked my file manager and main.cpp and #main.cpp# are in the location /home/ics45c/projects/proj1/app
Also I don't understand the other CMake errors after CMakeLists.txt either. What does it mean that it can't determine the linker language?
## Here is the CMakeLists.txt file ##
cmake_minimum_required(VERSION 3.10)
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(COMPILE_FLAGS "-stdlib=libc++ -Wall -pedantic-errors -Werror -g -fstandalone-debug")
project(a.out.app)
file(GLOB APP_SRC_FILES ${CMAKE_SOURCE_DIR}/app/*.cpp)
set(APP_SRC_FILES_EXCEPT_MAIN ${APP_SRC_FILES})
list(REMOVE_ITEM APP_SRC_FILES_EXCEPT_MAIN ${CMAKE_SOURCE_DIR}/app/main.cpp)
add_executable(${PROJECT_NAME} ${APP_SRC_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/app)
target_link_libraries(${PROJECT_NAME} pthread c++)
project(a.out.exp)
file(GLOB EXP_SRC_FILES ${CMAKE_SOURCE_DIR}/exp/*.cpp)
add_executable(${PROJECT_NAME} ${EXP_SRC_FILES} ${APP_SRC_FILES_EXCEPT_MAIN})
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/app)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/exp)
target_link_libraries(${PROJECT_NAME} pthread c++)
project(a.out.gtest)
file(GLOB GTEST_SRC_FILES ${CMAKE_SOURCE_DIR}/gtest/*.cpp)
add_executable(${PROJECT_NAME} ${GTEST_SRC_FILES} ${APP_SRC_FILES_EXCEPT_MAIN})
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/app)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/gtest)
target_link_libraries(${PROJECT_NAME} pthread c++ gtest gtest_main)
Line 49 is the error according to the CMake error but I have no idea why:
add_executable(${PROJECT_NAME} ${GTEST_SRC_FILES} ${APP_SRC_FILES_EXCEPT_MAIN})
I just don't understand any of this, and this is also my first Stackoverflow post.