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.
Related
I have a problem with Conan and Cmake:
With conan i'm downloading my libraries and i want to compile with Cmake, here is my CMakeLists.txt :
cmake_minimum_required(VERSION 3.16)
project(BABEL)
set(CMAKE_CXX_STANDARD 20)
set(PROJECT_NAME BABEL)
set(SOURCES qt/main.cpp)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
conan_basic_setup(KEEP_RPATHS)
if (APPLE)
set(CMAKE_INSTALL_RPATH "#executable_path/../lib")
endif (APPLE)
file(WRITE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf [Paths]\nPrefix=${CONAN_QT_ROOT})
add_executable(${PROJECT_NAME} ${SOURCES})
find_package(portaudio REQUIRED)
find_package(opus REQUIRED)
find_package(Qt5 COMPONENTS Widgets Network Core Gui REQUIRED)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
target_link_libraries(${PROJECT_NAME} opus)
if (WIN32)
target_link_libraries(${PROJECT_NAME} portaudio_x64)
else()
target_link_libraries(${PROJECT_NAME} portaudio)
endif()
if I write this command :
mkdir build && cd build && conan install .. && cmake .. -G "Unix Makefiles" && cmake --build.
I'll have to write cmake --build . a second time for the binary to be built, any idea of what i did wrong here ?
edit Here is the result of the build :
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/laurent/Documents/Delivery/Tek3/CPP/B-CPP-500-LYN-5-1-babel-kevin.melinon/build
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /Users/laurent/Documents/Delivery/Tek3/CPP/B-CPP-500-LYN-5-1-babel-kevin.melinon/build
-- Conan: Using autogenerated Findportaudio.cmake
-- Library portaudio found /Users/laurent/.conan/data/portaudio/19.7.0/bincrafters/stable/package/22e8f592c814313580425adf77089996d9853e39/lib/libportaudio.dylib
-- Found: /Users/laurent/.conan/data/portaudio/19.7.0/bincrafters/stable/package/22e8f592c814313580425adf77089996d9853e39/lib/libportaudio.dylib
-- Conan: Using autogenerated FindOpus.cmake
CMake Warning (dev) at /usr/local/Cellar/cmake/3.21.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to `find_package_handle_standard_args` (Opus) does
not match the name of the calling package (opus). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
build/Findopus.cmake:81 (find_package_handle_standard_args)
CMakeLists.txt:24 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
I can't put the full result.
So apparently there is a bug when writing all the command in one, typing them one by one solved the problem.
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 ()
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
I've been trying to change a makefile c++ project into a cmake project, and I've been having som difficulty. cmake seems to be looking for stuff in /usr/local/lib/ instead of /usr/local/include/ and I'm not sure why that is.
This library is header-only, and so I've been following this tutorial My header-only library in include seems to "build" fine, but I keep getting the following error when I try to generate a makefile to build my example program:
me:~/pf/examples/build$ cmake ..
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.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
CMake Error at /usr/local/lib/cmake/pf/pfConfig.cmake:27 (include):
include could not find load file:
/usr/local/lib/cmake/pf/pf_exampleTargets.cmake
Call Stack (most recent call first):
CMakeLists.txt:15 (find_package)
examples/CMakeLists.txt creates another fresh project:
project(pf_example)
cmake_minimum_required (VERSION 3.12)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_STANDARD 17)
# "install" pf
find_package(pf CONFIG REQUIRED)
find_package(Eigen3 3.3 REQUIRED NO_MODULE)
file(GLOB SOURCES ${PROJECT_NAME}/*.{h,cpp})
message("${SOURCES}")
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} pf::pf)
The root directory CMakeLists.txt file is more complicated. It's the one that was adapted from the tutorial I mentioned above:
cmake_minimum_required(VERSION 3.12)
project("pf" VERSION 1.0.1
DESCRIPTION "A header only c++ template library for fast particle filtering."
HOMEPAGE_URL "https://github.com/tbrown122387/pf")
include(GNUInstallDirs)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(
${PROJECT_NAME}
INTERFACE $<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
install(EXPORT ${PROJECT_NAME}_Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include DESTINATION include)
To install this header only library, before I try to build the examples project, I typed the following commands into the command line:
cd ~/pf
mkdir build
cd build/
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/include
sudo cmake --build . --config Release --target install -- -j $(nproc)
I didn't post it, but there's also a file cmake/pfconfig.cmake.in that is verbatim copied from the tutorial above.
Your install prefix is specified as /usr/local/include so the files would be installed as:
headers into /usr/local/include/include
libraries into /usr/local/include/libs
cmake stuff into /usr/local/include/share/${PROJECT_NAME}/cmake
Those paths are just wrong. Just set CMAKE_INSTALL_PREFIX=/usr/local (ie. remove include) and install it inside /usr/local/ tree.
A few took care of this issue.
in CMakeLists.txt change install(DIRECTORY ${PROJECT_SOURCE_DIR}/include DESTINATION include) to install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/pf DESTINATION include) so the files don't clutter up the installation locations. This also requires creating pf/include/pf and moving all the files in pf/include to pf/include/pf.
Follow advice in #KamilCuk's answer.
In examples/CMakeLists.txt change file(GLOB SOURCES ${PROJECT_NAME}/*.{h,cpp}) to file(GLOB SOURCES ${CMAKE_SOURCE_DIR}/*.h ${CMAKE_SOURCE_DIR}/*.cpp)
Also note that my /usr/local/lib and /usr/local/include were quite cluttered up due to my numerous earlier failed attempts, so I deleted a bunch of files in there and re-installed fresh.
im facing a problem with cmake when trying to compile libtins library to embedded device using arm-linux-gnueabi-g++
i must say that when im compiling the library for linux (not embedded) the cmake works fine! and no error is shown! like in this toturial: compiling libtins with linux
but i need the cross compiler option so i did these steps:
first i installed the arm cross compiler with the apt get command, second, i downloaded the libtins master directory from the official github and i created a build dir and used the cmake command in the libtins cross compile toturial here :
libtins cross compile
i change it a bit so i can use my own arm compiler and the command is:
cmake ../ -DCMAKE_FIND_ROOT_PATH=/usr/lib/ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabi-g++ -DLIBTINS_ENABLE_WPA2=0 -DCROSS_COMPILING=1
and i get this error in the terminal:
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 9.2.1
-- 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/arm-linux-gnueabi-g++
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabi-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'RelWithDebInfo' as none was specified.
-- Build will generate a shared library. Use LIBTINS_BUILD_SHARED=0 to perform a static build
CMake Error at /usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find PCAP (missing: PCAP_LIBRARY)
Call Stack (most recent call first):
/usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
cmake/Modules/FindPCAP.cmake:46 (find_package_handle_standard_args)
CMakeLists.txt:61 (FIND_PACKAGE)
but i did a lot of resarch in the web and added this line -DCMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu to the cmake command so i run this command in the terminal :
cmake ../ -DCMAKE_FIND_ROOT_PATH=/usr/lib/ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabi-g++ -DLIBTINS_ENABLE_WPA2=0 -DCROSS_COMPILING=1 -DCMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu
and it seems to find pcap but now i get another error:
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 9.2.1
-- 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/arm-linux-gnueabi-g++
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabi-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'RelWithDebInfo' as none was specified.
-- Build will generate a shared library. Use LIBTINS_BUILD_SHARED=0 to perform a static build
-- Found PCAP: /usr/lib/x86_64-linux-gnu/libpcap.so
-- Performing Test PCAP_LINKS_SOLO
-- Performing Test PCAP_LINKS_SOLO - Failed
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Performing Test PCAP_NEEDS_THREADS
-- Performing Test PCAP_NEEDS_THREADS - Failed
CMake Error at cmake/Modules/FindPCAP.cmake:70 (message):
Couldn't determine how to link against libpcap
Call Stack (most recent call first):
CMakeLists.txt:61 (FIND_PACKAGE)
-- Configuring incomplete, errors occurred!
See also "/root/Desktop/libtins-master/build/CMakeFiles/CMakeOutput.log".
See also "/root/Desktop/libtins-master/build/CMakeFiles/CMakeError.log".
my cmakeLists file looks like this:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.1)
PROJECT(libtins)
OPTION(LIBTINS_BUILD_EXAMPLES "Build examples" ON)
OPTION(LIBTINS_BUILD_TESTS "Build tests" ON)
# Compile in release mode by default
IF(NOT CMAKE_BUILD_TYPE)
MESSAGE(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
SET(CMAKE_BUILD_TYPE RelWithDebInfo)
ELSE(NOT CMAKE_BUILD_TYPE)
MESSAGE(STATUS "Using specified '${CMAKE_BUILD_TYPE}' build type.")
ENDIF(NOT CMAKE_BUILD_TYPE)
# Compilation flags.
IF(MSVC)
# Don't always use Wall, since VC's /Wall is ridiculously verbose.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
# Disable VC secure checks, since these are not really issues.
ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS=1")
ADD_DEFINITIONS("-D_SCL_SECURE_NO_WARNINGS=1")
ADD_DEFINITIONS("-DNOGDI=1")
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
ENDIF()
IF(APPLE)
# This is set to ON as of policy CMP0042
SET(CMAKE_MACOSX_RPATH ON)
ENDIF()
# Build output checks
OPTION(LIBTINS_BUILD_SHARED "Build libtins as a shared library." ON)
IF(LIBTINS_BUILD_SHARED)
MESSAGE(
STATUS
"Build will generate a shared library. "
"Use LIBTINS_BUILD_SHARED=0 to perform a static build"
)
SET(LIBTINS_TYPE SHARED)
ELSE(LIBTINS_BUILD_SHARED)
MESSAGE(STATUS "Build will generate a static library.")
SET(LIBTINS_TYPE STATIC)
ADD_DEFINITIONS("-DTINS_STATIC=1")
ENDIF(LIBTINS_BUILD_SHARED)
# The version number.
SET(TINS_VERSION_MAJOR 4)
SET(TINS_VERSION_MINOR 3)
SET(TINS_VERSION_PATCH 0)
SET(LIBTINS_VERSION "${TINS_VERSION_MAJOR}.${TINS_VERSION_MINOR}")
# Required Packages
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
# Allow disabling packet capture mechanism
OPTION(LIBTINS_ENABLE_PCAP "Enable capturing packets via libpcap" ON)
# Look for libpcap
IF(LIBTINS_ENABLE_PCAP)
FIND_PACKAGE(PCAP REQUIRED)
SET(TINS_HAVE_PCAP ON)
ENDIF()
# Set some Windows specific flags
IF(WIN32)
# We need to link against these libs
SET(LIBTINS_OS_LIBS Ws2_32.lib Iphlpapi.lib)
# Add the NOMINMAX macro to avoid Windows' min and max macros.
ADD_DEFINITIONS(-DNOMINMAX)
# MinWG need some extra definitions to compile properly (WIN32 for PCAP and WIN32_WINNT version for ws2tcpip.h)
IF(MINGW)
ADD_DEFINITIONS(-DWIN32)
MACRO(get_WIN32_WINNT version)
IF (WIN32 AND CMAKE_SYSTEM_VERSION)
SET(ver ${CMAKE_SYSTEM_VERSION})
STRING(REPLACE "." "" ver ${ver})
STRING(REGEX REPLACE "([0-9])" "0\\1" ver ${ver})
SET(${version} "0x${ver}")
ENDIF()
ENDMACRO()
get_WIN32_WINNT(ver)
ADD_DEFINITIONS(-D_WIN32_WINNT=${ver})
ENDIF(MINGW)
ENDIF(WIN32)
INCLUDE(ExternalProject)
# *******************
# Compilation options
# *******************
# Always check for C++ features
INCLUDE(CheckCXXFeatures)
IF(HAS_GCC_BUILTIN_SWAP)
SET(TINS_HAVE_GCC_BUILTIN_SWAP ON)
ENDIF()
# C++11 support
OPTION(LIBTINS_ENABLE_CXX11 "Compile libtins with c++11 features" ON)
IF(LIBTINS_ENABLE_CXX11)
# We only use declval and decltype on gcc/clang as VC fails to build that code,
# at least on VC2013
IF(HAS_CXX11_RVALUE_REFERENCES AND HAS_CXX11_FUNCTIONAL AND HAS_CXX11_CHRONO AND
HAS_CXX11_NOEXCEPT AND ((HAS_CXX11_DECLVAL AND HAS_CXX11_DECLTYPE) OR MSVC))
SET(TINS_HAVE_CXX11 ON)
MESSAGE(STATUS "Enabling C++11 features")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}")
ELSE()
MESSAGE(WARNING "The compiler doesn't support the necessary C++11 features. "
"Disabling C++11 on this build")
ENDIF()
ELSE(LIBTINS_ENABLE_CXX11)
MESSAGE(
WARNING
"Disabling C++11 features. Use LIBTINS_ENABLE_CXX11=1 to enable them. "
"Unless you are using an old compiler, you should enable this option, "
"as it increases the library's performance")
ENDIF(LIBTINS_ENABLE_CXX11)
# IEEE 802.11 and WPA2 decryption support
OPTION(LIBTINS_ENABLE_DOT11 "Compile libtins with IEEE 802.11 support" ON)
OPTION(LIBTINS_ENABLE_WPA2 "Compile libtins with WPA2 decryption features (requires OpenSSL)" ON)
IF(LIBTINS_ENABLE_DOT11)
SET(TINS_HAVE_DOT11 ON)
MESSAGE(STATUS "Enabling IEEE 802.11 support.")
IF(LIBTINS_ENABLE_WPA2)
FIND_PACKAGE(OpenSSL)
IF(OPENSSL_FOUND)
SET(TINS_HAVE_WPA2_DECRYPTION ON)
MESSAGE(STATUS "Enabling WPA2 decryption support.")
ELSE()
MESSAGE(WARNING "Disabling WPA2 decryption support since OpenSSL was not found")
# Default this to empty strings
SET(OPENSSL_INCLUDE_DIR "")
SET(OPENSSL_LIBRARIES "")
ENDIF()
ELSE(LIBTINS_ENABLE_WPA2)
MESSAGE(STATUS "Disabling WPA2 decryption support.")
ENDIF(LIBTINS_ENABLE_WPA2)
ENDIF(LIBTINS_ENABLE_DOT11)
# Optionally enable TCPIP classes (on by default)
OPTION(LIBTINS_ENABLE_TCPIP "Enable TCPIP classes" ON)
IF(LIBTINS_ENABLE_TCPIP AND TINS_HAVE_CXX11)
SET(TINS_HAVE_TCPIP ON)
MESSAGE(STATUS "Enabling TCPIP classes")
ELSE()
SET(TINS_HAVE_TCPIP OFF)
MESSAGE(STATUS "Disabling TCPIP classes")
ENDIF()
# Search for libboost
FIND_PACKAGE(Boost)
# Optionally enable the ACK tracker (on by default)
OPTION(LIBTINS_ENABLE_ACK_TRACKER "Enable TCP ACK tracking support" ON)
IF(LIBTINS_ENABLE_ACK_TRACKER AND TINS_HAVE_CXX11)
IF (Boost_FOUND)
MESSAGE(STATUS "Enabling TCP ACK tracking support.")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
SET(TINS_HAVE_ACK_TRACKER ON)
ELSE()
MESSAGE(WARNING "Disabling ACK tracking support as boost.icl was not found")
SET(TINS_HAVE_ACK_TRACKER OFF)
ENDIF()
ELSE()
SET(TINS_HAVE_ACK_TRACKER OFF)
MESSAGE(STATUS "Disabling ACK tracking support")
ENDIF()
# Optionally enable the TCP stream custom data (on by default)
OPTION(LIBTINS_ENABLE_TCP_STREAM_CUSTOM_DATA "Enable TCP stream custom data support" ON)
IF(LIBTINS_ENABLE_TCP_STREAM_CUSTOM_DATA AND TINS_HAVE_CXX11)
IF (Boost_FOUND)
MESSAGE(STATUS "Enabling TCP stream custom data support.")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
SET(TINS_HAVE_TCP_STREAM_CUSTOM_DATA ON)
ELSE()
MESSAGE(WARNING "Disabling TCP stream custom data support as boost.any was not found")
SET(TINS_HAVE_TCP_STREAM_CUSTOM_DATA OFF)
ENDIF()
ELSE()
SET(TINS_HAVE_TCP_STREAM_CUSTOM_DATA OFF)
MESSAGE(STATUS "Disabling TCP stream custom data support")
ENDIF()
OPTION(LIBTINS_ENABLE_WPA2_CALLBACKS "Enable WPA2 callback interface" ON)
IF(LIBTINS_ENABLE_WPA2_CALLBACKS AND TINS_HAVE_WPA2_DECRYPTION AND TINS_HAVE_CXX11)
SET(STATUS "Enabling WPA2 callback interface")
SET(TINS_HAVE_WPA2_CALLBACKS ON)
ENDIF()
# Use pcap_sendpacket to send l2 packets rather than raw sockets
IF(WIN32)
SET(USE_PCAP_SENDPACKET_DEFAULT ON)
ELSE(WIN32)
SET(USE_PCAP_SENDPACKET_DEFAULT OFF)
ENDIF(WIN32)
OPTION(LIBTINS_USE_PCAP_SENDPACKET "Use pcap_sendpacket to send l2 packets"
${USE_PCAP_SENDPACKET_DEFAULT})
IF(LIBTINS_ENABLE_PCAP AND LIBTINS_USE_PCAP_SENDPACKET)
SET(TINS_HAVE_PACKET_SENDER_PCAP_SENDPACKET ON)
MESSAGE(STATUS "Using pcap_sendpacket to send l2 packets.")
ENDIF()
# Add a target to generate API documentation using Doxygen
FIND_PACKAGE(Doxygen QUIET)
IF(DOXYGEN_FOUND)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
#ONLY
)
ADD_CUSTOM_TARGET(
docs
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
ENDIF(DOXYGEN_FOUND)
# Configuration file
CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/include/tins/config.h.in"
"${PROJECT_SOURCE_DIR}/include/tins/config.h"
)
IF (NOT CMAKE_INSTALL_LIBDIR)
SET(CMAKE_INSTALL_LIBDIR lib)
ENDIF()
IF (NOT CMAKE_INSTALL_BINDIR)
SET(CMAKE_INSTALL_BINDIR bin)
ENDIF()
# The library output directory
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
# Support for pkg-config
SET(pkgconfig_prefix ${CMAKE_INSTALL_PREFIX})
SET(pkgconfig_exec_prefix ${CMAKE_INSTALL_PREFIX})
SET(pkgconfig_libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
SET(pkgconfig_version ${LIBTINS_VERSION})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libtins.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libtins.pc #ONLY)
INSTALL(
FILES
${CMAKE_CURRENT_BINARY_DIR}/libtins.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
# Confiugure the uninstall script
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE #ONLY
)
# Add uninstall target
ADD_CUSTOM_TARGET(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
# ******************
# Add subdirectories
# ******************
ADD_SUBDIRECTORY(src)
IF(LIBTINS_BUILD_EXAMPLES)
IF(LIBTINS_ENABLE_PCAP)
ADD_SUBDIRECTORY(examples)
ELSE()
MESSAGE(STATUS "Not building examples as pcap support is disabled")
ENDIF()
ENDIF()
IF(LIBTINS_BUILD_TESTS)
# Only include googletest if the git submodule has been fetched
IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/googletest/CMakeLists.txt")
# Enable tests and add the test directory
MESSAGE(STATUS "Tests have been enabled")
SET(GOOGLETEST_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
SET(GOOGLETEST_INCLUDE ${GOOGLETEST_ROOT}/googletest/include)
SET(GOOGLETEST_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/googletest)
SET(GOOGLETEST_LIBRARY ${GOOGLETEST_BINARY_DIR}/googletest)
ExternalProject_Add(
googletest
DOWNLOAD_COMMAND ""
SOURCE_DIR ${GOOGLETEST_ROOT}
BINARY_DIR ${GOOGLETEST_BINARY_DIR}
CMAKE_CACHE_ARGS "-DBUILD_GTEST:bool=ON" "-DBUILD_GMOCK:bool=OFF"
"-Dgtest_force_shared_crt:bool=ON"
"-DCMAKE_CXX_COMPILER:path=${CMAKE_CXX_COMPILER}"
INSTALL_COMMAND ""
)
# Make sure we build googletest before anything else
ADD_DEPENDENCIES(tins googletest)
ENABLE_TESTING()
ADD_SUBDIRECTORY(tests)
ELSE()
MESSAGE(STATUS "googletest git submodule is absent. Run `git submodule init && git submodule update` to get it")
ENDIF()
ENDIF()
# **********************************
# CMake project configuration export
# **********************************
if(UNIX)
set(CONF_CMAKE_INSTALL_DIR lib/cmake/libtins)
else()
set(CONF_CMAKE_INSTALL_DIR CMake)
endif()
# Add all targets to the build-tree export set
EXPORT(
TARGETS tins
FILE "${PROJECT_BINARY_DIR}/libtinsTargets.cmake"
)
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
EXPORT(PACKAGE libtins)
# Create the libtinsConfig.cmake and libtinsConfigVersion.cmake files
# for the build tree
SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include")
CONFIGURE_FILE(
cmake/libtinsConfig.cmake.in
"${PROJECT_BINARY_DIR}/libtinsConfig.cmake" #ONLY
)
CONFIGURE_FILE(
cmake/libtinsConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/libtinsConfigVersion.cmake" #ONLY
)
# Install the libtinsConfig.cmake and libtinsConfigVersion.cmake
INSTALL(
FILES
"${PROJECT_BINARY_DIR}/libtinsConfig.cmake"
"${PROJECT_BINARY_DIR}/libtinsConfigVersion.cmake"
DESTINATION ${CONF_CMAKE_INSTALL_DIR}
COMPONENT dev
)
# Install the export set for use with the install-tree
INSTALL(
EXPORT libtinsTargets
DESTINATION ${CONF_CMAKE_INSTALL_DIR}
COMPONENT dev
)
i didnt touch it and im sure that the solution needs to be in this file and im a little lost with cmake files so any help will be great!