QT5 target_link_libraries can not find network library - qt5

All,
I am trying change QT pro file to cmake ,and found a error.
got a error
CMake Error at CMakeLists.txt:60 (target_link_libraries):
Target "opencvTest" links to:
Qt5::network
but the target was not found.
here is CMakeLists.txt
`
cmake_minimum_required(VERSION 3.5)
project(opencvTest VERSION 0.1 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "I:/Qt515/5.15.2/mingw81_64/lib/cmake")
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets network)
find_package(Qt5Network REQUIRED)
set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(opencvTest
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET opencvTest APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(opencvTest SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(opencvTest
${PROJECT_SOURCES}
)
endif()
endif()
set(OpenCV_DIR "${CMAKE_SOURCE_DIR}/../../b")
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(opencvTest PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::network)
target_link_libraries(opencvTest PRIVATE ${OpenCV_LIBS})
set_target_properties(opencvTest PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
install(TARGETS opencvTest
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(opencvTest)
endif()
`
win10 + QT 5.15.2 + mingw81_64
did I miss somethings?
if I replace Qt${QT_VERSION_MAJOR}::network to Qt${QT_VERSION_MAJOR}::Core or Gui , it works.
and also fail with Qt${QT_VERSION_MAJOR}::Multimedia.
If I remove Qt${QT_VERSION_MAJOR}::network, I will get a header file lost error.
fatal error: QCameraInfo: No such file or directory
#include <QCameraInfo>

Related

cmake : Boost, plog and other packages not found. Packages installed via vcpkg

I am building a cross-platform project using cmake in Visual Studios 2022 Community Edition.
I am unable to include library headers files and linker files.
Error
1> [CMake] Could NOT find Boost (missing: Boost_INCLUDE_DIR)
Top-level CMake project file
# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.8)
# Set vcpkg library path
set(CMAKE_TOOLCHAIN_FILE C:/vcpkg/scripts/buildsystems/vcpkg.cmake)
project ("Test")
# Include sub-projects.
add_subdirectory ("Test")
CMake project for Test
# CMakeList.txt : CMake project for Test, include source and define
# project specific logic here.
#
# Set to C++20 standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_BUILD_TYPE debug)
# Set to C17 standard
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
#add library packages
set(Boost_USE_STATIC_LIBS ON) # only find static libs
set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(Boost_USE_RELEASE_LIBS ON) # only find release libs
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(BOOST_INCLUDEDIR "C:\\vcpkg\\installed\\x64-windows-static\\include\\boost")
find_package(Boost REQUIRED)
if(Boost_FOUND)
message(${Boost_VERSION_STRING})
include_directories(${Boost_INCLUDE_DIR})
target_link_libraries(Test ${Boost_LIBRARIES})
endif()
find_package(pystring REQUIRED)
find_package(plog REQUIRED)
# Add source to this project's executable.
add_executable (Test main.cpp common.cpp MqttClient.cpp Protocol.cpp SerialPort.cpp)
if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET Test PROPERTY CXX_STANDARD 20)
endif()
# TODO: Add s and install targets if needed.

How to configure CMakeLists.txt for OpenMP?

I am building a python extension from c++ shared library.
This library is using some openmp pragma.
I would like to know how to configure CMakeLists.txt in order to include openmp ?
I have added the openmp flag -fopenmp
But I still have this error : undefined symbol: GOMP_critical_end
here is my CMakeLists.txt file
cmake_minimum_required(VERSION 3.10)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++lastest -pthread -fopenmp")
project (py_interface)
#find_library('gomp')
find_package(OpenMP REQUIRED)
find_package(Boost REQUIRED)
include_directories(/usr/include/python3.6/)
link_directories(/usr/local/lib)
set(SRC interface.cpp)
add_library(py_interface SHARED ${SRC})
target_link_libraries(py_interface PRIVATE OpenMP::OpenMP_CXX ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
set_property(TARGET py_interface PROPERTY POSITION_INDEPENDENT_CODE ON)

Unable to compile C++ program with tf2_ros header inclusion

I have installed ros2 dashing diademata. I wrote a ROS2 node using C++14. I would like to read static_tf by creating a buffer and TransformListener
I am getting the following error when I include, #include "tf2_ros/buffer.h" If I do not include, I do not get any error.
The error is as follows
In file included from /opt/ros/dashing/include/tf2/LinearMath/Vector3.h:21:0,
from /opt/ros/dashing/include/tf2/LinearMath/Matrix3x3.h:19,
from /opt/ros/dashing/include/tf2/LinearMath/Transform.h:21,
from /opt/ros/dashing/include/tf2/buffer_core.h:35,
from /opt/ros/dashing/include/tf2_ros/buffer_interface.h:37,
from /opt/ros/dashing/include/tf2_ros/buffer.h:35,
from /module/src/example/include/example/example.h:17,
from /module/src/example/src/example.cpp:7:
/opt/ros/dashing/include/tf2/LinearMath/Scalar.h: In function ‘tf2Scalar tf2Log(tf2Scalar)’:
/opt/ros/dashing/include/tf2/LinearMath/Scalar.h:187:66: error: expression cannot be used as a function
TF2SIMD_FORCE_INLINE tf2Scalar tf2Log(tf2Scalar x) { return log(x); }
CMakeLists.txt is as follows
cmake_minimum_required(VERSION 3.5)
project(curb_odometry)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Wdeprecated-declarations -Wunused-parameter)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2 REQUIRED)
find_package(message_filters REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
include_directories(include
${Boost_INCLUDE_DIRS}
${tf2_ros_INCLUDE_DIRS}
${rclcpp_INCLUDE_DIRS}
${sensor_msgs_INCLUDE_DIRS}
${geometry_msgs_INCLUDE_DIRS}
${nav_msgs_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${message_filters_INCLUDE_DIR}
)
link_directories(${Boost_LIBRARY_DIRS})
add_executable(example src/example.cpp src/curb_detection.cpp src/curb_odometry.cpp)
target_link_libraries(example ${Boost_LIBRARIES} )
target_include_directories(example PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
ament_target_dependencies(
example
"rclcpp"
"sensor_msgs"
"geometry_msgs"
"nav_msgs"
"std_msgs"
"boost"
"message_filters"
"geometry2"
"tf2_ros"
"tf2"
)
install(TARGETS example
EXPORT export_${PROJECT_NAME}
DESTINATION lib/${PROJECT_NAME})
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()
Looks like the error is coming from tf library. Any help in this regard will be appreciable.

Detect Sun Studio compiler and add platform libraries in CMakeList.txt?

Sun Studio 12.5 on Solaris 11.3. Solve one problem and move to the next... Building our project with CMake results the link error below.
I believe its a simple matter of detecting SunCC and adding -lnsl -lsocket to LDLIBS. However, the method to detect the SunCC compiler escapes me. I found an old post from 2006 that states (from Error detecting sun studio compiler under linux):
I am trying to use the sun studio compiler under linux and I am having a
terrible time getting past the cmake compiler tests.
AFAIK no one has tried CMake with this compiler before.... CMake is invoking the compiler assuming that it accepts the flags other Linux compilers (such as GNU and Intel) accept... You'll have to setup a platform file to configure this compiler.
I tried to use SunPro from CMake Compiler IDs, but it results in the same error shown below.
if(SunPro)
target_link_libraries(cryptopp-shared nsl socket)
target_link_libraries(cryptest nsl socket)
endif()
My question is, how do I detect the Sun Studio compiler in CMakeList.txt? Or how do I detect Solaris?
/opt/developerstudio12.5/bin/CC -DNDEBUG -g2 -O2 -D__SSE2__ -D__SSE3__ -D__SSSE3__
-D__SSE4_1__ -D__SSE4_2__ -D__AES__ -D__PCLMUL__ -D__RDRND__ -D__RDSEED__ -D__AVX__
-D__AVX2__ -D__BMI__ -D__BMI2__ -D__ADX__ -xarch=avx2_i
CMakeFiles/cryptest.dir/bench1.cpp.o CMakeFiles/cryptest.dir/bench2.cpp.o
CMakeFiles/cryptest.dir/test.cpp.o CMakeFiles/cryptest.dir/validat1.cpp.o
CMakeFiles/cryptest.dir/validat2.cpp.o CMakeFiles/cryptest.dir/validat3.cpp.o
CMakeFiles/cryptest.dir/datatest.cpp.o CMakeFiles/cryptest.dir/regtest.cpp.o
CMakeFiles/cryptest.dir/fipsalgt.cpp.o CMakeFiles/cryptest.dir/dlltest.cpp.o
CMakeFiles/cryptest.dir/fipstest.cpp.o -o cryptest.exe libcryptopp.a
Undefined first referenced
symbol in file
bind libcryptopp.a(socketft.cpp.o)
recv libcryptopp.a(socketft.cpp.o)
send libcryptopp.a(socketft.cpp.o)
getservbyname libcryptopp.a(socketft.cpp.o)
getsockname libcryptopp.a(socketft.cpp.o)
accept libcryptopp.a(socketft.cpp.o)
listen libcryptopp.a(socketft.cpp.o)
gethostbyname libcryptopp.a(socketft.cpp.o)
socket libcryptopp.a(socketft.cpp.o)
setsockopt CMakeFiles/cryptest.dir/test.cpp.o
connect libcryptopp.a(socketft.cpp.o)
getpeername libcryptopp.a(socketft.cpp.o)
inet_addr libcryptopp.a(socketft.cpp.o)
shutdown libcryptopp.a(socketft.cpp.o)
ld: fatal: symbol referencing errors
gmake[2]: *** [cryptest.exe] Error 2
gmake[2]: Leaving directory `/export/home/cryptopp-build'
gmake[1]: *** [CMakeFiles/cryptest.dir/all] Error 2
gmake[1]: Leaving directory `/export/home/cryptopp-build'
gmake: *** [all] Error 2
Here's the CMakeList.tx file. It has not been checked in yet, so I have to dump it here:
$ cat CMakeLists.txt
# Please ensure your changes or patch meets minimum requirements.
# The minimum requirements are below, and they are 2.8.5. Please
# do not check in something for 2.8.12. To test your changes,
# please set up a Ubuntu 12.04 LTS system. Then, manually install
# CMake 2.8.5 from http://cmake.org/Wiki/CMake_Released_Versions.
cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)
project(cryptopp)
set(cryptopp_VERSION_MAJOR 5)
set(cryptopp_VERSION_MINOR 6)
set(cryptopp_VERSION_PATCH 5)
include(GNUInstallDirs)
include(TestBigEndian)
#============================================================================
# Settable options
#============================================================================
option(BUILD_STATIC "Build static library" ON)
option(BUILD_SHARED "Build shared library" ON)
option(BUILD_TESTING "Build library tests" ON)
option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" OFF)
option(DISABLE_ASM "Disable ASM" OFF)
option(DISABLE_SSSE3 "Disable SSSE3" OFF)
option(DISABLE_AESNI "Disable AES-NI" OFF)
set(CRYPTOPP_DATA_DIR "" CACHE PATH "Crypto++ test data directory")
#============================================================================
# Internal compiler options
#============================================================================
# Don't use RPATH's. The resulting binary could fail a security audit.
if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
set(CMAKE_MACOSX_RPATH 0)
endif()
set(LIB_VER ${cryptopp_VERSION_MAJOR}${cryptopp_VERSION_MINOR}${cryptopp_VERSION_PATCH})
if(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_definitions(-wd68 -wd186 -wd279 -wd327 -wd161 -wd3180)
endif()
# Endianess
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
if(IS_BIG_ENDIAN)
add_definitions(-DIS_BIG_ENDIAN)
endif()
if(DISABLE_ASM)
add_definitions(-DCRYPTOPP_DISABLE_ASM)
endif()
if(DISABLE_SSSE3)
add_definitions(-DCRYPTOPP_DISABLE_SSSE3)
endif()
if(DISABLE_AESNI)
add_definitions(-DCRYPTOPP_DISABLE_AESNI)
endif()
if(NOT CRYPTOPP_DATA_DIR STREQUAL "")
add_definitions(-DCRYPTOPP_DATA_DIR="${CRYPTOPP_DATA_DIR}")
endif()
if(WINDOWS_STORE OR WINDOWS_PHONE)
if("${CMAKE_SYSTEM_VERSION}" MATCHES "10\\.0.*")
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D\"_WIN32_WINNT=0x0A00\"" )
endif()
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FI\"winapifamily.h\"" )
endif()
#============================================================================
# Sources & headers
#============================================================================
# Library headers
file(GLOB cryptopp_HEADERS *.h)
# Test sources. You can use the GNUmakefile to generate the list: `make sources`.
file(GLOB cryptopp_SOURCES_TEST bench1.cpp bench2.cpp test.cpp validat1.cpp validat2.cpp validat3.cpp adhoc.cpp datatest.cpp regtest.cpp fipsalgt.cpp dlltest.cpp fipstest.cpp)
# Library sources. You can use the GNUmakefile to generate the list: `make sources`.
file(GLOB cryptopp_SOURCES *.cpp)
list(REMOVE_ITEM cryptopp_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/cryptlib.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cpu.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/simple.cpp
${CMAKE_CURRENT_SOURCE_DIR}/winpipes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cryptlib_bds.cpp
${cryptopp_SOURCES_TEST}
)
set(cryptopp_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/cryptlib.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cpu.cpp
${cryptopp_SOURCES}
)
if(MINGW OR WIN32)
list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/winpipes.cpp)
endif()
if(MSVC AND NOT DISABLE_ASM)
if(${CMAKE_GENERATOR} MATCHES ".*ARM")
message(STATUS "Disabling ASM because ARM is specified as target platform.")
else()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/x64dll.asm)
list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/x64masm.asm)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/x64dll.asm PROPERTIES COMPILE_FLAGS "/D_M_X64")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/x64masm.asm PROPERTIES COMPILE_FLAGS "/D_M_X64")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/rdrand.asm PROPERTIES COMPILE_FLAGS "/D_M_X64")
else()
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/x64dll.asm PROPERTIES COMPILE_FLAGS "/D_M_X86 /safeseh")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/x64masm.asm PROPERTIES COMPILE_FLAGS "/D_M_X86 /safeseh")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/rdrand.asm PROPERTIES COMPILE_FLAGS "/D_M_X86 /safeseh")
endif()
list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/rdrand.asm)
enable_language(ASM_MASM)
endif()
endif()
#============================================================================
# Compile targets
#============================================================================
# Set global includes BEFORE adding any targets for legacy CMake versions
if(CMAKE_VERSION VERSION_LESS 2.8.12)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
endif()
if(NOT CMAKE_VERSION VERSION_LESS 2.8.8)
add_library(cryptopp-object OBJECT ${cryptopp_SOURCES})
endif()
if (BUILD_STATIC)
if(NOT CMAKE_VERSION VERSION_LESS 2.8.8)
add_library(cryptopp-static STATIC $<TARGET_OBJECTS:cryptopp-object>)
else()
add_library(cryptopp-static STATIC ${cryptopp_SOURCES})
endif()
if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
target_include_directories(cryptopp-static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include/cryptopp>)
endif()
endif()
if (BUILD_SHARED)
if(NOT CMAKE_VERSION VERSION_LESS 2.8.8)
add_library(cryptopp-shared SHARED $<TARGET_OBJECTS:cryptopp-object>)
else()
add_library(cryptopp-shared SHARED ${cryptopp_SOURCES})
endif()
if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
target_include_directories(cryptopp-shared PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include/cryptopp>)
endif()
endif()
# Set PIC
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
# Enables -fPIC on all 64-bit platforms
if(NOT CMAKE_VERSION VERSION_LESS 2.8.9) # POSITION_INDEPENDENT_CODE support
set_target_properties(cryptopp-object PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
elseif(NOT CMAKE_VERSION VERSION_LESS 2.8.8) # Object library support
get_target_property(flags_old cryptopp-object COMPILE_FLAGS)
set_target_properties(cryptopp-object PROPERTIES COMPILE_FLAGS "${flags_old} -fPIC")
else()
if (BUILD_STATIC)
get_target_property(flags_old_static cryptopp-static COMPILE_FLAGS)
if(NOT flags_old_static)
set(flags_old_static "")
endif()
set_target_properties(cryptopp-static PROPERTIES COMPILE_FLAGS "${flags_old_static} -fPIC")
endif()
if (BUILD_SHARED)
get_target_property(flags_old_shared cryptopp-shared COMPILE_FLAGS)
if(NOT flags_old_shared)
set(flags_old_shared "")
endif()
set_target_properties(cryptopp-shared PROPERTIES COMPILE_FLAGS "${flags_old_shared} -fPIC")
endif()
endif()
endif()
# Set filenames for targets to be "cryptopp"
if(NOT MSVC)
set(COMPAT_VERSION ${cryptopp_VERSION_MAJOR}.${cryptopp_VERSION_MINOR})
if (BUILD_STATIC)
set_target_properties(cryptopp-static
PROPERTIES
OUTPUT_NAME cryptopp)
endif()
if (BUILD_SHARED)
set_target_properties(cryptopp-shared
PROPERTIES
SOVERSION ${COMPAT_VERSION}
OUTPUT_NAME cryptopp)
endif()
endif()
# Targets, compatible with Crypto++ GNUMakefile
if (BUILD_STATIC)
add_custom_target(static)
add_dependencies(static cryptopp-static)
endif()
if (BUILD_SHARED)
add_custom_target(dynamic)
add_dependencies(dynamic cryptopp-shared)
endif()
#============================================================================
# Third-party libraries
#============================================================================
if(WIN32)
if (BUILD_STATIC)
target_link_libraries(cryptopp-static ws2_32)
endif()
if (BUILD_SHARED)
target_link_libraries(cryptopp-shared ws2_32)
endif()
endif()
if(SunPro)
target_link_libraries(cryptopp-shared nsl socket)
target_link_libraries(cryptest nsl socket)
endif()
find_package(Threads)
if (BUILD_STATIC)
target_link_libraries(cryptopp-static ${CMAKE_THREAD_LIBS_INIT})
endif()
if (BUILD_SHARED)
target_link_libraries(cryptopp-shared ${CMAKE_THREAD_LIBS_INIT})
endif()
#============================================================================
# Tests
#============================================================================
enable_testing()
if(BUILD_TESTING)
add_executable(cryptest ${cryptopp_SOURCES_TEST})
target_link_libraries(cryptest cryptopp-static)
# Setting "cryptest" binary name to "cryptest.exe"
if(NOT WIN32)
set_target_properties(cryptest PROPERTIES OUTPUT_NAME cryptest.exe)
endif()
if(NOT TARGET cryptest.exe)
add_custom_target(cryptest.exe)
add_dependencies(cryptest.exe cryptest)
endif()
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/TestData DESTINATION ${PROJECT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/TestVectors DESTINATION ${PROJECT_BINARY_DIR})
add_test(NAME build_cryptest COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target cryptest)
add_test(NAME cryptest COMMAND $<TARGET_FILE:cryptest> v)
set_tests_properties(cryptest PROPERTIES DEPENDS build_cryptest)
endif()
#============================================================================
# Doxygen documentation
#============================================================================
if(BUILD_DOCUMENTATION)
find_package(Doxygen REQUIRED)
set(in_source_DOCS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/html-docs")
set(out_source_DOCS_DIR "${PROJECT_BINARY_DIR}/html-docs")
add_custom_target(docs ALL
COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile -d CRYPTOPP_DOXYGEN_PROCESSING
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
)
if(NOT ${in_source_DOCS_DIR} STREQUAL ${out_source_DOCS_DIR})
add_custom_command(
TARGET docs POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${in_source_DOCS_DIR}" "${out_source_DOCS_DIR}"
COMMAND ${CMAKE_COMMAND} -E remove_directory "${in_source_DOCS_DIR}"
)
endif()
endif()
#============================================================================
# Install
#============================================================================
set(export_name "cryptopp-targets")
# Runtime package
if (BUILD_SHARED)
install(
TARGETS cryptopp-shared
EXPORT ${export_name}
DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()
# Development package
if (BUILD_STATIC)
install(TARGETS cryptopp-static EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
install(FILES ${cryptopp_HEADERS} DESTINATION include/cryptopp)
# CMake Package
if(NOT CMAKE_VERSION VERSION_LESS 2.8.8) # CMakePackageConfigHelpers is supported from 2.8.8
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake" VERSION ${cryptopp_VERSION_MAJOR}.${cryptopp_VERSION_MINOR}.${cryptopp_VERSION_PATCH} COMPATIBILITY SameMajorVersion)
install(FILES cryptopp-config.cmake ${PROJECT_BINARY_DIR}/cryptopp-config-version.cmake DESTINATION "lib/cmake/cryptopp")
install(EXPORT ${export_name} DESTINATION "lib/cmake/cryptopp")
endif()
# Tests
if(BUILD_TESTING)
install(TARGETS cryptest DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/TestData DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cryptopp)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/TestVectors DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cryptopp)
endif()
# Documentation
if(BUILD_DOCUMENTATION)
install(DIRECTORY "${out_source_DOCS_DIR}" DESTINATION ${CMAKE_INSTALL_DOCDIR})
endif()

Assimp with cmake

I want to include assimp to my project using CMake. I have Ubuntu 14.04 LTE and QTCreator.
Project contain of main.cpp and linked libraries stored in libs directory.
Main CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(test)
find_package(OpenGL REQUIRED)
# libs contain external libaries
add_subdirectory (libs)
include_directories(
libs/glfw-3.0.4/include
libs/assimp-3.1.1/include/
)
set(allLibs
${GLFW_LIBRARIES}
${OPENGL_LIBRARY}
GLEW_LIB
assimp
)
add_executable(test
main/main.cpp
)
target_link_libraries(Manipulator glfw assimp ${allLibs} )
CMakeList.txt inside libs directory
### GLFW ###
add_subdirectory (glfw-3.0.4)
include_directories(
glfw-3.0.4/include/GLFW/
glew-1.11.0/include/
assimp-3.1.1/include/
)
set(OPENGL_LIBRARY
-lGL -lGLU -lXrandr -lXext -lX11 -lrt
${CMAKE_DL_LIBS}
${GLFW_LIBRARIES}
)
### GLEW ###
set(GLEW_SOURCE
glew-1.11.0/src/glew.c
)
add_library( GLEW_LIB STATIC
${GLEW_SOURCE}
)
target_link_libraries(GLEW_LIB
${OPENGL_LIBRARY}
)
### ASSIMP ###
# Zlib
add_subdirectory( assimp-3.1.1/contrib/zlib )
# Boost workaround
include_directories( assimp-3.1.1/code/BoostWorkaround )
add_definitions( -DASSIMP_BUILD_BOOST_WORKAROUND )
# Compile AssImp
add_subdirectory( assimp-3.1.1/code )
And I receive following error.
CMake Error at libs/assimp-3.1.1/code/CMakeLists.txt:725 (INSTALL):
install TARGETS given no ARCHIVE DESTINATION for static library target
"assimp".
This point's me to this
INSTALL( TARGETS assimp # 725 line
LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR}
COMPONENT ${LIBASSIMP_COMPONENT})
How to correctly link this library?
This is a CMakeList.txt that I use to build my project.
All external libraries were stored in libs directory. Main file was stored in main directory.
cmake_minimum_required (VERSION 2.6)
project (Project name)
find_package(OpenGL REQUIRED)
#Adding external CMakeList.txt files
add_subdirectory(libs/glfw-3.1)
#add GLEW as STATIC library
add_library(GLEW STATIC libs/glew-1.11.0/src/glew.c libs/glew-1.11.0/include/GL/glew.h)
#add include directories
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
common/
libs/glfw-3.1/include/
libs/glew-1.11.0/include/
libs/glm/
libs/assimp-3.1.1/include/
libs/CImg_162/CImg.h
)
# set variables that are needed
set(ZLIB_LIBRARIES zlibstatic)
set(ENABLE_BOOST_WORKAROUND ON)
set(BUILD_STATIC_LIB ON)
set(BUILD_ASSIMP_TOOLS ON)
set(ASSIMP_BUILD_STATIC_LIB ON)
add_subdirectory(libs/assimp-3.1.1)
#Add my own liblary
add_subdirectory(common)
set(extLibs
${extLibs}
${GLFW_LIBRARIES}
)
add_executable (openGL main/main.cpp
Source/vertexShader.vs
Source/fragmentShader.fs
)
target_link_libraries(openGL common assimp GLEW glfw ${GLFW_LIBRARIES})
CMakelist.txt from Common looks like this:
add_library(common model.cpp)
This should work on Ubuntu 14.04. If some libraries are missing try to follow steps from this tutorial tutorial