CMake Unable to find static boost libraries - c++

I was attempting to compile the cryptonote code for testing purposes and I recived this error on my CMake Build:
However, I confirmed that my Boost files are in the correct directory:
F:/boost_1_67_0/boost_1_67_0/libs
How do I make CMake recognize this?
Attached is my CMakeList.txt, I hope this helps
cmake_minimum_required(VERSION 2.8.6)
set(VERSION "0.1")
# $Format:Packaged from commit %H%nset(COMMIT %h)%nset(REFS "%d")$
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CONFIGURATION_TYPES Debug RelWithDebInfo Release CACHE TYPE INTERNAL)
set(CMAKE_SKIP_INSTALL_RULES ON)
set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY ON)
set(CMAKE_SUPPRESS_REGENERATION ON)
enable_testing()
# copy CTestCustom.cmake to build dir to disable long running tests in 'make test'
configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR})
project(CryptoNote)
include_directories(include src external "${CMAKE_BINARY_DIR}/version")
if(APPLE)
include_directories(SYSTEM /usr/include/malloc)
enable_language(ASM)
endif()
if(MSVC)
include_directories(src/Platform/Windows)
elseif(APPLE)
include_directories(src/Platform/OSX)
else()
include_directories(src/Platform/Linux)
endif()
set(STATIC ${MSVC} CACHE BOOL "Link libraries statically")
if(MSVC)
add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /D_VARIADIC_MAX=8 /D__SSE4_1__")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10485760")
if(STATIC)
foreach(VAR CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE)
string(REPLACE "/MD" "/MT" ${VAR} "${${VAR}}")
endforeach()
endif()
include_directories(SYSTEM src/platform/msc)
else()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
# This option has no effect in glibc version less than 2.20.
# Since glibc 2.20 _BSD_SOURCE is deprecated, this macro is recomended instead
add_definitions("-D_DEFAULT_SOURCE -D_GNU_SOURCE")
endif()
set(ARCH native CACHE STRING "CPU to build for: -march value or default")
if("${ARCH}" STREQUAL "default")
set(ARCH_FLAG "")
else()
set(ARCH_FLAG "-march=${ARCH}")
endif()
set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Werror -Wno-error=extra -Wno-error=unused-function -Wno-error=deprecated-declarations -Wno-error=sign-compare -Wno-error=strict-aliasing -Wno-error=type-limits -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized -Wno-error=unused-result")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(WARNINGS "${WARNINGS} -Wno-error=mismatched-tags -Wno-error=null-conversion -Wno-overloaded-shift-op-parentheses -Wno-error=shift-count-overflow -Wno-error=tautological-constant-out-of-range-compare -Wno-error=unused-private-field -Wno-error=unneeded-internal-declaration -Wno-error=unused-function")
else()
set(WARNINGS "${WARNINGS} -Wlogical-op -Wno-error=maybe-uninitialized -Wno-error=clobbered -Wno-error=unused-but-set-variable")
endif()
if(MINGW)
set(WARNINGS "${WARNINGS} -Wno-error=unused-value")
set(MINGW_FLAG "-DWIN32_LEAN_AND_MEAN")
include_directories(SYSTEM src/platform/mingw)
else()
set(MINGW_FLAG "")
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.1))
set(WARNINGS "${WARNINGS} -Wno-error=odr")
endif()
set(C_WARNINGS "-Waggregate-return -Wnested-externs -Wold-style-definition -Wstrict-prototypes")
set(CXX_WARNINGS "-Wno-reorder -Wno-missing-field-initializers")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 ${MINGW_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG} -maes")
if(NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG} -maes")
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_HAS_TR1_TUPLE=0")
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8))
set(DEBUG_FLAGS "-g3 -Og")
else()
set(DEBUG_FLAGS "-g3 -O0")
endif()
set(RELEASE_FLAGS "-Ofast -DNDEBUG -Wno-unused-variable")
if(NOT APPLE)
# There is a clang bug that does not allow to compile code that uses AES-NI intrinsics if -flto is enabled
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux"
AND CMAKE_BUILD_TYPE STREQUAL "Release" AND ((CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.9) OR (CMAKE_C_COMPILER_VERSION VERSION_EQUAL 4.9)))
# On linux, to build in lto mode, check that ld.gold linker is used: 'update-alternatives --install /usr/bin/ld ld /usr/bin/ld.gold HIGHEST_PRIORITY'
set(CMAKE_AR gcc-ar)
set(CMAKE_RANLIB gcc-ranlib)
endif()
set(RELEASE_FLAGS "${RELEASE_FLAGS} -flto")
endif()
#if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT MINGW)
# set(RELEASE_FLAGS "${RELEASE_FLAGS} -fno-fat-lto-objects")
#endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEBUG_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${RELEASE_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${RELEASE_FLAGS}")
if(STATIC AND NOT APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
endif()
endif()
if(STATIC)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)
endif()
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "F:/boost_1_67_0/boost_1_67_0")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "F:/boost_1_67_0/boost_1_67_0/libs")
find_package(Boost 1.55 REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
if(MINGW)
set(Boost_LIBRARIES "${Boost_LIBRARIES};ws2_32;mswsock")
elseif(APPLE)
set(Boost_LIBRARIES "${Boost_LIBRARIES}")
elseif(NOT MSVC)
set(Boost_LIBRARIES "${Boost_LIBRARIES};rt")
endif()
set(COMMIT_ID_IN_VERSION ON CACHE BOOL "Include commit ID in version")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/version")
if (NOT COMMIT_ID_IN_VERSION)
set(VERSION "${VERSION}-unknown")
configure_file("src/version.h.in" "version/version.h")
add_custom_target(version ALL)
elseif(DEFINED COMMIT)
string(REPLACE "." "\\." VERSION_RE "${VERSION}")
if(NOT REFS MATCHES "(\\(|, )tag: v${VERSION_RE}(\\)|, )")
set(VERSION "${VERSION}-g${COMMIT}")
endif()
configure_file("src/version.h.in" "version/version.h")
add_custom_target(version ALL)
else()
find_package(Git QUIET)
if(Git_FOUND OR GIT_FOUND)
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
add_custom_target(version ALL "${CMAKE_COMMAND}" "-D" "VERSION=${VERSION}" "-D" "GIT=${GIT_EXECUTABLE}" "-D" "TO=${CMAKE_BINARY_DIR}/version/version.h" "-P" "src/version.cmake" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
else()
message(STATUS "WARNING: Git was not found!")
set(VERSION "${VERSION}-unknown")
configure_file("src/version.h.in" "version/version.h")
add_custom_target(version ALL)
endif()
endif()
add_subdirectory(external)
add_subdirectory(src)
add_subdirectory(tests)
Thank you so much!!

Related

Use existing CMake library in a new project including its headers

I'm working on a project where I have an existing CMake library (https://github.com/OpenEtherCATsociety/SOEM) stored in project/lib/SOEM/.
The source for my application lives in project/src/
I have a root CMakeLists.txt which adds both subdirectories.
Now my question is how do I link the SOEM library to my executable and also use its headers without relative paths?
SOEM contains its own CMakeLists.txt which I would preferably not touch at all if that's possible. It builds a library and installs it together with its headers, however, I don't know how to make use of the latter.
cmake_minimum_required(VERSION 2.8.4)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")
project(SOEM C)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# Default to installing in SOEM source directory
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install)
endif()
set(SOEM_INCLUDE_INSTALL_DIR include/soem)
if(WIN32)
set(OS "win32")
include_directories(oshw/win32/wpcap/Include)
link_directories(${CMAKE_SOURCE_DIR}/oshw/win32/wpcap/Lib)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_NO_WARNINGS")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
set(OS_LIBS wpcap.lib Packet.lib Ws2_32.lib Winmm.lib)
elseif(UNIX)
set(OS "linux")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror")
set(OS_LIBS pthread rt)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "rt-kernel")
set(OS "rtk")
message("ARCH is ${ARCH}")
message("BSP is ${BSP}")
include_directories(oshw/${OS}/${ARCH})
file(GLOB OSHW_EXTRA_SOURCES oshw/${OS}/${ARCH}/*.c)
set(OSHW_SOURCES "${OS_HW_SOURCES} ${OSHW_ARCHSOURCES}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format")
set(OS_LIBS "-Wl,--start-group -l${BSP} -l${ARCH} -lkern -ldev -lsio -lblock -lfs -lusb -llwip -leth -li2c -lrtc -lcan -lnand -lspi -lnor -lpwm -ladc -ltrace -lc -lm -Wl,--end-group")
endif()
message("OS is ${OS}")
file(GLOB SOEM_SOURCES soem/*.c)
file(GLOB OSAL_SOURCES osal/${OS}/*.c)
file(GLOB OSHW_SOURCES oshw/${OS}/*.c)
file(GLOB SOEM_HEADERS soem/*.h)
file(GLOB OSAL_HEADERS osal/osal.h osal/${OS}/*.h)
file(GLOB OSHW_HEADERS oshw/${OS}/*.h)
include_directories(soem)
include_directories(osal)
include_directories(osal/${OS})
include_directories(oshw/${OS})
add_library(soem STATIC
${SOEM_SOURCES}
${OSAL_SOURCES}
${OSHW_SOURCES}
${OSHW_EXTRA_SOURCES})
target_link_libraries(soem ${OS_LIBS})
install(TARGETS soem DESTINATION lib)
install(FILES
${SOEM_HEADERS}
${OSAL_HEADERS}
${OSHW_HEADERS}
DESTINATION ${SOEM_INCLUDE_INSTALL_DIR})
add_subdirectory(test/linux/slaveinfo)
add_subdirectory(test/linux/eepromtool)
add_subdirectory(test/linux/simple_test)

CMAKE+QT MAC how to set deployment target?

I use cmake + qt in the development of mac os x 10.12 platform, but when I use the set (CMAKE_OSX_DEPLOYMENT_TARGET "10.11") compiler generated app, the app copy to mac os x 10.11 on the computer application, prompted app need os X 10.12, but if not copy the app to the application, copy to other directories will not prompt the need for os x 10.12, very strange question, my app also depends on a lot of other dylib, please help me analyze this problem.
The following is the cmake code:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
#set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11")
PROJECT(toon)
set(PACKAGE "toon")
set(TOON_VERSION "1.1.0")
set(XCODE_BUILD "")
IF(APPLE)
#set(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS}")
MESSAGE(STATUS "CMAKE_CXX_FLAGS:" ${CMAKE_CXX_FLAGS})
MESSAGE(STATUS "DEPLOYMENT_TARGET:" ${CMAKE_OSX_DEPLOYMENT_TARGET})
MESSAGE(STATUS "CMAKE_OSX_SYSROOT:" ${CMAKE_OSX_SYSROOT})
ENDIF()
#set(CMAKE_BUILD_TYPE Debug)
#set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-std=c++11")
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
IF(CMAKE_BUILD_TYPE MATCHES "Release")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
ELSEIF(CMAKE_BUILD_TYPE MATCHES "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -Wall -g")
MESSAGE(STATUS "build_type:" ${CMAKE_BUILD_TYPE})
MESSAGE(STATUS "cxx_flags:" ${CMAKE_CXX_FLAGS_DEBUG})
ENDIF()
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(MY_PRODUCT_NUMBER 1)
set(MY_PRODUCT_VERSION 1)
set(MY_BUILD_NUMBER 2)
ENDIF()
IF(APPLE)
set(CMAKE_MACOSX_RPATH ON)
#set(INSTALL_LIB_DIR "${PROJECT_SOURCE_DIR}/toonsdk/build/x64/Debug") # 假设安装目录在编译目录的lib子目录内
#set(CMAKE_SKIP_BUILD_RPATH FALSE)
#set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
#set(CMAKE_INSTALL_RPATH "${PROJECT_SOURCE_DIR}/toonsdk/build/x64/Debug")
#set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
IF(CMAKE_BUILD_TYPE MATCHES "Release")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
ELSEIF(CMAKE_BUILD_TYPE MATCHES "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -Wall -g")
ENDIF()
ENDIF()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
ADD_SUBDIRECTORY(Common)
ADD_SUBDIRECTORY(LocalStorage)
ADD_SUBDIRECTORY(NetWorkAPI)
ADD_SUBDIRECTORY(IMCore)
ADD_SUBDIRECTORY(ToonProtocol)
ADD_SUBDIRECTORY(TNMVD)
ADD_SUBDIRECTORY(Notice)
ADD_SUBDIRECTORY(SetUp)
ADD_SUBDIRECTORY(CardCase)
#ADD_SUBDIRECTORY(Upgrade)
ADD_SUBDIRECTORY(Mine)
ADD_SUBDIRECTORY(Toon)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9") sloved;

How to modify CMakelists for Qt5 from Windows to Linux?

(problem already solved)
It will compile if just $qtcreator openglwindow/openglwindow.pro for Qt5-OpenGL-example(http://doc.qt.io/qt-5/qtgui-openglwindow-example.html)
My CMakelist can be build on Win10, but on linux fail, the command is:
[user]$ mkdir build && cd build && cmake .. && make
it outputs error as follow:
Scanning dependencies of target QtGL_test_automoc
[ 20%] Automatic mocfor target QtGL_test
Generating moc source QtGL_test_automoc.dir/moc_openglwindow_LRW7M26ARLGWDK.cpp
Generating moc compilation QtGL_test_automoc.cpp
[ 20%] Built target
QtGL_test_automoc Scanning dependencies of target QtGL_test
[ 40%] Building CXX object CMakeFiles/QtGL_test.dir/main.cpp.o
c++: fatal error: no input files compilation terminated.
/bin/sh:-DQT_CORE_LIB: command not found
make[2]: *** [CMakeFiles/QtGL_test.dir/build.make:63: MakeFiles/QtGL_test.dir/main.cpp.o] Error 127
make[1]: ***[CMakeFiles/Makefile2:68: CMakeFiles/QtGL_test.dir/all] Error 2 make:
*** [Makefile:84: all] Error 2
I'd tried to figure out how to modify a cross-platform version for linux.
Here is my CMakeLists.txt:
cmake_minimum_required (VERSION 3.5)
set(PRROJ_NAME QtGL_test)
project (${PRROJ_NAME})
set(HEADERS ${HEADERS} openglwindow.h )
set(SOURCES ${SOURCES} main.cpp ${HEADERS})
set(CMAKE_AUTOMOC ON)
add_executable(${PRROJ_NAME} ${SOURCES})
set(PROJ_INCLUDE_DIRS ${PROJ_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR})
add_library(openglwindow openglwindow.cpp)
set(PROJ_LIBRARIES ${PROJ_LIBRARIES} openglwindow)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(WIN32)
find_path(CMAKE_PREFIX_PATH NAMES lib/cmake/Qt5/Qt5Config.cmake HINTS
"$ENV{Qt5_ROOT}"
)
message("Qt5_ROOT is $ENV{Qt5_ROOT}")
endif()
message("CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
set(NEED_QT_COMPONENTS QTCORE QTGUI)
message("finding ${NEED_QT_COMPONENTS}")
foreach(COMPONENT Gui Core)
message("find_package(Qt5${COMPONENT})")
find_package("Qt5${COMPONENT}")
message("Qt5${COMPONENT}_FOUND is ${Qt5${COMPONENT}_FOUND}")
if("${Qt5${COMPONENT}_FOUND}")
set(PROJ_INCLUDE_DIRS ${PROJ_INCLUDE_DIRS} "${Qt5${COMPONENT}_INCLUDE_DIRS}")
set(PROJ_LIBRARIES ${PROJ_LIBRARIES} "Qt5::${COMPONENT}")
add_definitions("${Qt5${COMPONENT}_DEFINITIONS}")
qt5_use_modules(${PRROJ_NAME} ${COMPONENT})
endif()
endforeach(COMPONENT )
message("include_directories(${PROJ_INCLUDE_DIRS})")
include_directories(${PROJ_INCLUDE_DIRS})
message("target_link_libraries(${PRROJ_NAME} ${PROJ_LIBRARIES})")
target_link_libraries(${PRROJ_NAME} ${PROJ_LIBRARIES})
set(CMAKE_CXX_STANDARD 14)
if(UNIX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include -Wall")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
endif()
finally solved version:
cmake_minimum_required (VERSION 3.5)
set(PRROJ_NAME QtGL_test)
project (${PRROJ_NAME})
set(HEADERS ${HEADERS} openglwindow.h )
set(SOURCES ${SOURCES} main.cpp ${HEADERS})
set(CMAKE_AUTOMOC ON)
add_executable(${PRROJ_NAME} ${SOURCES})
set(PROJ_INCLUDE_DIRS ${PROJ_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR})
add_library(openglwindow openglwindow.cpp)
set(PROJ_LIBRARIES ${PROJ_LIBRARIES} openglwindow)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(WIN32)
find_path(CMAKE_PREFIX_PATH NAMES lib/cmake/Qt5/Qt5Config.cmake HINTS
"$ENV{Qt5_ROOT}"
)
message("Qt5_ROOT is $ENV{Qt5_ROOT}")
endif()
message("CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
set(QT_FLAGS "-fPIC")
set(NEED_QT_COMPONENTS QTCORE QTGUI)
message("finding ${NEED_QT_COMPONENTS}")
foreach(COMPONENT Gui Core)
message("find_package(Qt5${COMPONENT})")
find_package("Qt5${COMPONENT}")
message("Qt5${COMPONENT}_FOUND is ${Qt5${COMPONENT}_FOUND}")
if("${Qt5${COMPONENT}_FOUND}")
set(PROJ_INCLUDE_DIRS ${PROJ_INCLUDE_DIRS} "${Qt5${COMPONENT}_INCLUDE_DIRS}")
set(PROJ_LIBRARIES ${PROJ_LIBRARIES} "Qt5::${COMPONENT}")
#Open add_definitions will error
#add_definitions("${Qt5${COMPONENT}_DEFINITIONS}")
qt5_use_modules(${PRROJ_NAME} ${COMPONENT})
endif()
endforeach(COMPONENT )
message("include_directories(${PROJ_INCLUDE_DIRS})")
include_directories(${PROJ_INCLUDE_DIRS})
message("target_link_libraries(${PRROJ_NAME} ${PROJ_LIBRARIES})")
target_link_libraries(${PRROJ_NAME} ${PROJ_LIBRARIES})
set(CMAKE_CXX_STANDARD 14)
if(UNIX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QT_FLAGS} -I/usr/local/include -Wall")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
endif()

issue related to cmake and openmp

I am trying to compile a program on QT creator with cmake. The code(its not my code, I am using it to test something) uses openMP. in my cmake file I have:
`enter code here`project(dbscan_try)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
SET(CMAKE_CXX_FLAGS "{CMAKE_CXX_FLAGS} -std=c++11 -Wall -fPIC -pedantic -fopenmp -mtune=corei7-avx")
set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) add_definitions(-DBOOST_UBLAS_NDEBUG) add_definitions("-std=c++11") add_definitions("-fopenmp")
add_definitions("-lgomp")
OPTION (USE_OpenMP "Use OpenMP" ON)
find_package(OpenMP)
if (OPENMP_FOUND)
message("OPENMP FOUND")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fopenmp")
find_package(PCL REQUIRED COMPONENTS) include_directories(${PCL_INCLUDE_DIRS} ) link_directories(${PCL_LIBRARY_DIRS}) add_definitions(${PCL_DEFINITIONS})
include_directories({/home/raman/Work/dbscan_try})
set(project_SOURCES
/home/raman/Work/cplusplus_projects/dbscan_try/main.cpp
/home/raman/Work/cplusplus_projects/dbscan_try/dbscan.cpp )
set(project_HEADERS
/home/raman/Work/cplusplus_projects/dbscan_try/dbscan.h)
set(OpenCV_INCLUDE_DIRS "${OpenCV_INSTALL_PATH}/include/opencv;${OpenCV_INSTALL_PATH}/include")
find_package(OpenCV 3.1.0 REQUIRED COMPONENTS) include_directories(-L/usr/local/lib -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_saliency -lboost_system -lopencv_contrib) set( CMAKE_CXX_FLAGS "-g -Wall")
add_executable(${PROJECT_NAME} ${project_SOURCES})
target_link_libraries(dbscan_try ${PCL_LIBRARIES} ${OpenCV_LIBS} )
However, I am getting errors such as:
/home/raman/Work/cplusplus_projects/dbscan_try/dbscan.cpp:88: error: undefined reference to omp_set_num_threads'
/home/raman/Work/cplusplus_projects/dbscan_try/dbscan.cpp:89: error: undefined reference toGOMP_parallel_start'
etc.
I am new to C++ and cmake so I am not sure if I am doing somethign wrong here. I seem to have followed what other suggestions here mentioned and it worked for them.

configure code blocks according to two cmake file

I am new to opencv i am trying to find the feature points in face in opencv 3.0 . I am using CLM framework .The examples in the frame work build perfectly when i build it using cmake . I found a CMakelists.txt in the root directory of the frame work and in the example folder . Can anyone help me to configure code blocks according to these 2 cmake file or help me to make a single cmake file to execte my project.
CMakelists.txt [in root folder]
cmake_minimum_required (VERSION 2.6)
project (CLM_framework)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
if(WIN32)
include_directories(lib/3rdParty/OpenCV3.0/include)
include_directories(lib/3rdParty/OpenCV3.0/include/opencv)
if(MSVC_VERSION == 1600)
link_directories( ${PROJECT_SOURCE_DIR}/lib/3rdParty/OpenCV3.0/x86/v100/lib )
endif(MSVC_VERSION)
if(MSVC_VERSION == 1700)
link_directories( ${PROJECT_SOURCE_DIR}/lib/3rdParty/OpenCV3.0/x86/v110/lib )
endif(MSVC_VERSION)
set(OpenCVLibraries
debug opencv_world300d
optimized opencv_world300
)
if (MSVC)
if(MSVC_VERSION == 1600)
file(GLOB files "lib/3rdParty/OpenCV3.0/x86/v100/bin/*.dll")
endif(MSVC_VERSION)
if(MSVC_VERSION == 1700)
file(GLOB files "lib/3rdParty/OpenCV3.0/x86/v110/bin/*.dll")
endif(MSVC_VERSION)
foreach(file ${files})
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/Release)
endforeach()
foreach(file ${files})
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/Debug)
endforeach()
endif(MSVC)
endif(WIN32)
if(UNIX)
find_package( OpenCV 3.0 REQUIRED )
find_package( Boost REQUIRED COMPONENTS filesystem system)
MESSAGE("Boost information:")
MESSAGE(" Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
MESSAGE(" Boost_LIBRARIES: ${Boost_LIBRARIES}")
MESSAGE(" Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}/boost)
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
endif(UNIX)
find_package(TBB REQUIRED)
# Move CLM model
file(GLOB files "lib/local/CLM/model/*.txt")
foreach(file ${files})
if (MSVC)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/Debug/model)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/Release/model)
else(MSVC)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/model)
endif(MSVC)
endforeach()
file(GLOB files "lib/local/CLM/model/detection_validation/*.txt")
foreach(file ${files})
if (MSVC)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/Debug/model/detection_validation)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/Release/model/detection_validation)
else(MSVC)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/model/detection_validation)
endif(MSVC)
endforeach()
file(GLOB files "lib/local/CLM/model/patch_experts/*.txt")
foreach(file ${files})
if (MSVC)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/Debug/model/patch_experts)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/Release/model/patch_experts)
else(MSVC)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/model/patch_experts)
endif(MSVC)
endforeach()
file(GLOB files "lib/local/CLM/model/pdms/*.txt")
foreach(file ${files})
if (MSVC)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/Debug/model/pdms)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/Release/model/pdms)
else(MSVC)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/model/pdms)
endif(MSVC)
endforeach()
# Move OpenCV classifiers
file(GLOB files "lib/3rdParty/OpenCV3.0/classifiers/*.xml")
foreach(file ${files})
if (MSVC)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/Debug/classifiers)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/Release/classifiers)
else(MSVC)
file(COPY ${file} DESTINATION ${CMAKE_BINARY_DIR}/bin/classifiers)
endif(MSVC)
endforeach()
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_LESS 4.7)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -msse -msse2 -msse3")
else ()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -msse -msse2 -msse3")
endif ()
else ()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -msse -msse2 -msse3")
endif ()
# Boost
if(WIN32)
include_directories(lib/3rdParty/boost)
include_directories(lib/3rdParty/boost/boost)
link_directories( ${PROJECT_SOURCE_DIR}/lib/3rdParty/boost/lib )
else()
INCLUDE_DIRECTORIES(${BOOST_INCLUDE_DIR})
endif()
# dlib
include_directories(lib/3rdParty/dlib/include)
# dlib library
add_subdirectory(lib/3rdParty/dlib)
# CLM library (ordering matters)
add_subdirectory(lib/local/CLM)
add_subdirectory(lib/local/FaceAnalyser)
# executables
add_subdirectory(exe/SimpleCLMImg)
add_subdirectory(exe/SimpleCLM)
add_subdirectory(exe/MultiTrackCLM)
add_subdirectory(exe/FeatureExtraction)
CMakelists.txt [in exe/MultiTrackCLM]
# Local libraries
include_directories(${CLM_SOURCE_DIR}/include)
include_directories(../../lib/local/CLM/include)
add_executable(MultiTrackCLM MultiTrackCLM.cpp)
target_link_libraries(MultiTrackCLM CLM)
target_link_libraries(MultiTrackCLM dlib)
if(WIN32)
target_link_libraries(MultiTrackCLM ${OpenCVLibraries})
endif(WIN32)
if(UNIX)
target_link_libraries(MultiTrackCLM ${OpenCV_LIBS} ${Boost_LIBRARIES} ${TBB_LIBRARIES})
endif(UNIX)
install (TARGETS MultiTrackCLM DESTINATION ${CMAKE_BINARY_DIR}/bin)