How to debug CGAL generated with cmake - debugging

I would like to Step thorugh my CGAL code, because it doesn't work.
Wiht Linux I only get assembler. What do I need to do to debug it?
I have set:
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_C_FLAGS_DEBUG "-g DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g DEBUG")
set(CMAKE_DONT_OVERRIDE_CMAKE_FLAGS=True)
Here the beginning of my CMakeList.txt. The rest is auto generated with cgal_create_CMakeLists:
# Created by the script cgal_create_CMakeLists
# This is the CMake script for compiling a set of CGAL applications.
cmake_minimum_required(VERSION 3.1...3.23)
project( MySurfaceMesh )
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG")
set(DCGAL_DONT_OVERRIDE_CMAKE_FLAGS=TRUE)
# CGAL and its components
find_package( CGAL QUIET COMPONENTS )
if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.")
return()
endif()
# Boost and its components
find_package( Boost REQUIRED )
.........

Related

"make" comment does not work after "cmake" on Mac OSX

Trying to install a plugin to Gazebo 11 on my Macbook Air M1. I will try to perform co-simulation between Simulink and Gazebo. After extracting gazeboplugin.zip , I applied
mkdir build
cd build
Then I tried
cmake ..
I got an error
CMake Error at CMakeLists.txt:32 (message):
The compiler /Library/Developer/CommandLineTools/usr/bin/c++ has no C++11
support. Please use a different C++ compiler.
Then I solved this by changing cmakelists.txt from
#/* Copyright 2019-2020 The MathWorks, Inc. */
##########################################
# CMakeLists.txt for gazebo_plugin_for_simulink #
##########################################
cmake_minimum_required(VERSION 2.8)
PROJECT(gazebo_plugin_for_simulink)
#################################
# Specify the CMake module path #
#################################
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native")
# Check C++11 or C++0x support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions(-DCOMPILEDWITHC11)
message(STATUS "Using flag -std=c++11.")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
add_definitions(-DCOMPILEDWITHC0X)
message(STATUS "Using flag -std=c++0x.")
elseif(COMPILER_SUPPORTS_CXX17)
set (CMAKE_CXX_STANDARD 17)
message(STATUS "Using C++17 standard")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++ -Wno-deprecated-declarations -Wno-unused-function")
ENDIF()
find_package(Boost 1.58.0 REQUIRED COMPONENTS date_time)
find_package(gazebo REQUIRED)
# Gazebo Minumum Supported version number
SET(GAZEBO_MIN_SUPPORTED_VERSION "9")
# Gazebo Maximum Supported version number
SET(GAZEBO_MAX_SUPPORTED_VERSION "11")
message(STATUS "Found Gazebo ${GAZEBO_VERSION}: major version is ${GAZEBO_MAJOR_VERSION}")
# Validate Installed Gazebo version
if("${GAZEBO_MAJOR_VERSION}" VERSION_LESS "${GAZEBO_MIN_SUPPORTED_VERSION}" OR "${GAZEBO_MAJOR_VERSION}" VERSION_GREATER "${GAZEBO_MAX_SUPPORTED_VERSION}" )
message(FATAL_ERROR "\nThe installed version of Gazebo is not supported for Gazebo Co-Simulation Plugin generation.\n"
" The Gazebo Co-Simulation Plugin supports,\n"
" minimum Gazebo version: gazebo ${GAZEBO_MIN_SUPPORTED_VERSION}.x series\n"
" maximum Gazebo version: gazebo ${GAZEBO_MAX_SUPPORTED_VERSION}.x series\n")
endif()
include_directories(
include/
msgsproto/
${Boost_INCLUDE_DIR}
${GAZEBO_INCLUDE_DIRS}
)
link_directories(
${GAZEBO_LIBRARY_DIRS}
)
###############################################
# USE => cmake .. -DTESTING=ON to trun ON testing
option(TESTING "plugin testing" OFF)
if(TESTING)
ADD_SUBDIRECTORY(msgsproto/pkgtest)
endif()
ADD_SUBDIRECTORY(msgsproto)
ADD_SUBDIRECTORY(src/transport)
ADD_SUBDIRECTORY(src/gazeboserver)
ADD_SUBDIRECTORY(src/gazebocustom)
ADD_SUBDIRECTORY(src/gazeboplugin)
if(TESTING)
ADD_SUBDIRECTORY(src/gazeboplugin/pkgtest)
ADD_SUBDIRECTORY(src/gazeboserver/gazebomsghandler/pkgtest)
ADD_SUBDIRECTORY(src/gazebocustom/gazebocustommsghandler/pkgtest)
endif()
to
# Sets the C++ compiler
# Available: C++11, C++14 and C++17
cmake_minimum_required(VERSION 3.25)
project(ProjectName)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if( (${CMAKE_VERSION} VERSION_GREATER "3.8.2") OR (${CMAKE_VERSION} VERSION_EQUAL "3.8.2") )
if(COMPILER_SUPPORTS_CXX17)
set (CMAKE_CXX_STANDARD 17)
message(STATUS "Using C++17 standard")
elseif(COMPILER_SUPPORTS_CXX14)
set (CMAKE_CXX_STANDARD 14)
message(STATUS "Using C++14 standard")
elseif(COMPILER_SUPPORTS_CXX11)
set (CMAKE_CXX_STANDARD 11)
message(STATUS "Using C++11 standard")
elseif(COMPILER_SUPPORTS_CXX0X)
set (CMAKE_CXX_STANDARD 11)
message(STATUS "Using C++11 standard")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 or above support. Please use a different C++ compiler.")
endif()
else()
if(COMPILER_SUPPORTS_CXX14)
set (CMAKE_CXX_STANDARD 14)
message(STATUS "Using C++14 standard")
elseif(COMPILER_SUPPORTS_CXX11)
set (CMAKE_CXX_STANDARD 11)
message(STATUS "Using C++11 standard")
elseif(COMPILER_SUPPORTS_CXX0X)
set (CMAKE_CXX_STANDARD 11)
message(STATUS "Using C++11 standard")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 or above support. Please use a different C++ compiler.")
endif()
endif()
After solving ( I guess ) this issue I got this after making cmake ..
mfurkanozata#Furkans-MacBook-Air build % cmake ..
-- Using C++17 standard
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/mfurkanozata/src/GazeboPlugin
Finally I aplly make command and got nothing. The plugin was not built and as usual after applying
gazebo ../world/multiSensorPluginTest.world --verbose
I got this error
[Err] [Plugin.hh:212] Failed to load plugin lib/libGazeboCoSimPlugin.so: dlopen(lib/libGazeboCoSimPlugin.so, 0x0009): tried: 'lib/libGazeboCoSimPlugin.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlib/libGazeboCoSimPlugin.so' (no such file), '/opt/homebrew/Cellar/gazebo11/11.12.0_2/lib/../lib/lib/libGazeboCoSimPlugin.so' (no such file), '/opt/homebrew/Cellar/gazebo11/11.12.0_2/bin/../lib/lib/libGazeboCoSimPlugin.so' (no such file), '/usr/lib/lib/libGazeboCoSimPlugin.so' (no such file, not in dyld cache), 'lib/libGazeboCoSimPlugin.so' (no such file)
Failed to load plugin lib/libGazeboCoSimPlugin.dylib: dlopen(lib/libGazeboCoSimPlugin.dylib, 0x0009): tried: 'lib/libGazeboCoSimPlugin.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlib/libGazeboCoSimPlugin.dylib' (no such file), '/opt/homebrew/Cellar/gazebo11/11.12.0_2/lib/../lib/lib/libGazeboCoSimPlugin.dylib' (no such file), '/opt/homebrew/Cellar/gazebo11/11.12.0_2/bin/../lib/lib/libGazeboCoSimPlugin.dylib' (no such file), '/usr/lib/lib/libGazeboCoSimPlugin.dylib' (no such file, not in dyld cache), 'lib/libGazeboCoSimPlugin.dylib' (no such file)
Can you help me in this issue?

OpenMP CMake Apple

I am currently trying to compile a project on Mac using cmake, but running into trouble. I have already looked at this article [1], but am still running into some trouble. My CMakeLists.txt looks as follows.
project(tpch_framework)
# enable c++11
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_C_COMPILER "/usr/local/Cellar/llvm/10.0.0_3/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/local/Cellar/llvm/10.0.0_3/bin/clang++")
set(OPENMP_LIBRARIES "/usr/local/Cellar/llvm/10.0.0_3/lib")
set(OPENMP_INCLUDES "/usr/local/Cellar/llvm/10.0.0_3/include")
OPTION (USE_OpenMP "Use OpenMP to enamble <omp.h>" ON)
# Find OpenMP
if(APPLE AND USE_OpenMP)
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp")
set(OpenMP_C_LIB_NAMES "omp")
set(OpenMP_omp_LIBRARY omp)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp")
set(OpenMP_CXX_LIB_NAMES "omp")
set(OpenMP_omp_LIBRARY omp)
endif()
endif()
if(USE_OpenMP)
find_package(OpenMP REQUIRED)
endif(USE_OpenMP)
if (OPENMP_FOUND)
include_directories("${OPENMP_INCLUDES}")
link_directories("${OPENMP_LIBRARIES}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} -libomp")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -libomp")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif(OPENMP_FOUND)
# Configure required Boost libraries
set(BOOST_ROOT "" CACHE PATH "Boost build root (useful on Windows)")
option(Boost_USE_STATIC_LIBS
"Search for static boost libs" OFF)
option(Boost_USE_MULTITHREADED
"Search for multithreaded boost libs" ON)
option(Boost_USE_STATIC_RUNTIME
"Search for boost libs linked against static C++ runtime" OFF)
find_package(Boost 1.47.0 REQUIRED filesystem system)
# ensure that dependant libraries not explicitly specified here
# are found by the linker:
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})
#Bring the headers into the project
include_directories(include)
FILE(GLOB_RECURSE INC_ALL "include/*.hpp")
#However, the file(GLOB...) allows for wildcard additions:
file(GLOB SOURCES "src/*.cpp")
add_library(tpch_framework ${SOURCES})
add_executable(framework main.cpp ${INC_ALL})
target_link_libraries(framework tpch_framework)
#target_link_libraries(framework stdc++fs)
target_link_libraries(framework ${LIBS})
When I execute this, I get the following output.
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- 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
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_C: -Xpreprocessor -fopenmp
-- Found OpenMP_CXX: -Xpreprocessor -fopenmp
-- Found OpenMP: TRUE
-- Found Boost: /usr/local/lib/cmake/Boost-1.72.0/BoostConfig.cmake (found suitable version "1.72.0", minimum required is "1.47.0") found components: filesystem system
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/...
However, when I then use make, I get the following error.
/Users/myname/Desktop/Uni/MHD/tpch_framework_challenge_mhd_2020/src/task4.cpp:48:5: error: use of undeclared identifier 'omp_set_num_threads'
omp_set_num_threads(4);
Which I am guessing comes, as I get this warning: clang-10: warning: -libomp: 'linker' input unused [-Wunused-command-line-argument].
Does anybody have any ideas? I have been stuck with this for way too long and would appreciate any tips.
Kind regards,
Moritz
If you can use a recent version of CMake, this build should work.
# NOTE: Every top-level CMakeLists.txt must start with these two lines
cmake_minimum_required(VERSION 3.16)
project(tpch_framework)
## Enable C++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
## Find dependencies
# OpenMP
find_package(OpenMP REQUIRED)
# Boost
set(BOOST_ROOT "" CACHE PATH "Boost build root (useful on Windows)")
option(Boost_USE_STATIC_LIBS
"Search for static boost libs" OFF)
option(Boost_USE_MULTITHREADED
"Search for multithreaded boost libs" ON)
option(Boost_USE_STATIC_RUNTIME
"Search for boost libs linked against static C++ runtime" OFF)
find_package(Boost 1.47.0 REQUIRED COMPONENTS filesystem system)
## Add main project targets
# NOTE: This is completely wrong and will break incremental builds after
# doing a "git pull" or similar. You should never glob for source
# files, but instead list them explicitly.
file(GLOB SOURCES "src/*.cpp")
add_library(tpch_framework ${SOURCES})
target_include_directories(tpch_framework PUBLIC BUILD_INTERFACE:include)
target_link_libraries(tpch_framework
PUBLIC
OpenMP::OpenMP_CXX
Boost::boost
Boost::filesystem
Boost::system)
add_executable(framework main.cpp)
target_link_libraries(framework PRIVATE tpch_framework)
There is so much bad CMake advice here on SO and in tutorials, it's a real shame.

CMAKE 3.8, imported targets not available for Boost version

I'm on Windows 10 and got this error when generating solution using CMake-GUI:
CMake Warning at C:/Program Files/CMake/share/cmake-3.8/Modules/FindBoost.cmake:765 (message):
Imported targets not available for Boost version
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.8/Modules/FindBoost.cmake:869 (_Boost_COMPONENT_DEPENDENCIES)
C:/Program Files/CMake/share/cmake-3.8/Modules/FindBoost.cmake:1472 (_Boost_MISSING_DEPENDENCIES)
I know it's been asked and answered here CMake finds Boost but the imported targets not available for Boost version
but the solution in there (upgrading CMake) doesn't work for me, still get the same error after upgrading from 3.7 to 3.8
Update
My boost version is 106300.
Content of CMakeList file is below:
# doc/CMakeLists.txt uses configure_file behavior from CMake 2.8
cmake_minimum_required(VERSION 2.8)
project(tpie)
include_directories(.)
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
#### CONFIG.H Checks:
include(CheckIncludeFiles)
if(NOT WIN32)
add_definitions("-Wall -Wextra")
endif(NOT WIN32)
if(WIN32)
add_definitions("-DWIN32_LEAN_AND_MEAN /bigobj")
endif(WIN32)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
#### Dependencies
## Boost
set(Boost_ADDITIONAL_VERSIONS "1.40.0" "1.40" "1.41" "1.41.0" "1.42" "1.42.0" "1.43" "1.43.0" "1.44" "1.44.0" "1.45" "1.45.0")
set(Boost_USE_MULTITHREADED ON)
if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
endif(WIN32)
find_package(Boost COMPONENTS date_time filesystem system REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
link_directories( ${Boost_LIBRARY_DIRS} )
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
if(TPIE_FRACTIONDB_DIR_INL)
include_directories(${TPIE_FRACTIONDB_DIR_INL})
endif(TPIE_FRACTIONDB_DIR_INL)
check_include_files("unistd.h" TPIE_HAVE_UNISTD_H)
check_include_files("sys/unistd.h" TPIE_HAVE_SYS_UNISTD_H)
# Ryan Pavlik's Git revision description helper
# http://stackoverflow.com/a/4318642
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_COMMIT)
## Snappy
option(TPIE_USE_SNAPPY "Use Snappy, a fast compressor/decompressor" ON)
if(TPIE_USE_SNAPPY)
find_package(Snappy)
if(${Snappy_FOUND})
set(TPIE_HAS_SNAPPY ON)
include_directories(${Snappy_INCLUDE_DIR})
else(${Snappy_FOUND})
set(TPIE_HAS_SNAPPY OFF)
endif(${Snappy_FOUND})
endif(TPIE_USE_SNAPPY)
#### Installation paths
#Default paths
set(BIN_INSTALL_DIR bin)
set(LIB_INSTALL_DIR lib)
set(HEADERS_INSTALL_DIR include/tpie)
if (WIN32)
set(DOC_INSTALL_DIR doc)
else(WIN32)
set(DOC_INSTALL_DIR "share/doc/tpie")
endif(WIN32)
set(INSTALL_TARGETS_DEFAULT_ARGS
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if (CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} bt)
string(REGEX MATCH " -DNDEBUG " TPIE_NDEBUG " ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${bt}} ")
else()
option(TPIE_NDEBUG "Disable debugging information" ON)
endif()
set(TPIE_S ${CMAKE_CURRENT_SOURCE_DIR})
set(TPIE_B ${CMAKE_CURRENT_BINARY_DIR})
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tpie/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/tpie/config.h)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tpie/config.h DESTINATION ${HEADERS_INSTALL_DIR})
add_subdirectory(tpie)
add_subdirectory(doc)
option(COMPILE_TEST "Compile test programs" ON)
option(TPL_LOGGING "Enable tpie logging." ON)
option(TPIE_DEPRECATED_WARNINGS "Enable warnings for deprecated classes, methods and typedefs" OFF)
option(TPIE_PARALLEL_SORT "Enable parallel quick sort implementation" ON)
if (COMPILE_TEST)
ENABLE_TESTING()
add_subdirectory(test)
add_subdirectory(apps)
endif (COMPILE_TEST)
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_CONTACT "rav#cs.au.dk")
set(CPACK_GENERATOR TGZ)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "TPIE")
set(CPACK_PACKAGE_VENDOR "The TPIE maintainers")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.md")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "TPIE ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
if(WIN32 AND NOT UNIX)
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backlasshes.
#set(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\thomasmoelhave.github.com/tpie/")
set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\thomasmoelhave.github.com/tpie/")
set(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT})
set(CPACK_NSIS_MODIFY_PATH ON)
list(APPEND CPACK_GENERATOR NSIS)
else(WIN32 AND NOT UNIX)
list(APPEND CPACK_GENERATOR DEB)
endif(WIN32 AND NOT UNIX)
install(DIRECTORY tpie
DESTINATION include
FILES_MATCHING REGEX "\\.h$|\\.inl$"
PATTERN "deadcode" EXCLUDE)
install(DIRECTORY share/tpie
DESTINATION share)
include(CPack)
Any other idea? tks
Your CMAKE is too old for the boost 1.63.
Reinstall a newer CMAKE or do this(according to FindBoost.cmake source code in cmake/share/cmake-3.9/Modules/FindBoost.cmake line 516):
Note: to add a new Boost release, run
% cmake -DBOOST_DIR=/path/to/boost/source -P Utilities/Scripts/BoostScanDeps.cmake
Or, Just modify that line from
elseif(NOT Boost_VERSION VERSION_LESS 106200 AND Boost_VERSION VERSION_LESS 106300)
to
elseif(NOT Boost_VERSION VERSION_LESS 106200 AND Boost_VERSION VERSION_LESS 106500)

Boost generated successfully but can't generate a makefile. Where did I go wrong?

Even though CMake has successfully configured and generated the makefile with Boost, I just can't produce an executable file for ARM processor using the make command as shown below.
Here is my configuration setting:
1.) I downloaded boost library 1.49 compiled in Raspberry Pi in this link:
http://www.raspberrypi.org/phpBB3/viewtopic.php?t=8111&p=195468
2.) The file hierarchy is as follows:
sample-boost
-> boost-stage (Contains the lib, and include directories of the boost taken from number 1)
-> build (Contains the generated files from CMake)
-> CMakeLists.txt
-> main.cpp
NOTE: The ARM Cross Compiler is fully working and I've cross compiled a hello world and run it in Raspberry Pi successfully using CMake in Cygwin (using a cross toolchain file located in C:/cygwin/arm-pi.toolchain.cmake).
main.cpp
#include <iostream>
#include <boost/thread.hpp>
int main(){
cout << "Hello" << endl;
boost::this_thread::sleep(boost::posix_time::millisec(20));
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
Project(main)
SET(Boost_INCLUDE_DIR C:/Users/Emmett/Documents/EMMETT/sample-boost/boost-stage/include)
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/Users/Emmett/Documents/EMMETT/sample-boost/boost-stage/include")
SET(BOOST_ROOT C:/Users/Emmett/Documents/EMMETT/sample-boost/boost-stage)
FIND_PACKAGE(Boost)
message("BOOST LIBRARY" ${Boost_LIBRARY_DIRS})
message("Boost LIBRARIES:" ${Boost_LIBRARIES})
IF(Boost_FOUND)
message("Boost include directory is found")
message("Boost_INCLUDE_DIRS": ${Boost_INCLUDE_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
add_executable(main main.cpp)
target_link_libraries( main ${Boost_LIBRARIES} )
ENDIF(Boost_FOUND)
Boost-stage
-> include (came from sample-boost\boost_1_49_0\boost)
-> lib (came from boost_1_49_0(bin-only)\lib
Also, invoking ccmake . shows that boost_dir is not found. However, boost package is found!
As you can see, it has successfully generated makefiles using CMake but I can't create an executable file for it. I think I missed out something in setting up boost. Maybe I've failed to successfully link the libraries? Does not the
message("Boost LIBRARIES:" ${Boost_LIBRARIES})
display the library files?
ADDITION: I did what you ask for. Here is my new cmakelists.txt
cmake_minimum_required(VERSION 2.8)
Project(main)
SET(Boost_INCLUDE_DIR C:/Users/Emmett/Documents/EMMETT/sample-boost/boost-stage/include)
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/Users/Emmett/Documents/EMMETT/sample-boost/boost-stage/include")
SET(BOOST_ROOT C:/Users/Emmett/Documents/EMMETT/sample-boost/boost-stage)
SET(Boost_USE_STATIC_LIBS TRUE)
SET(Boost_DEBUG ON)
#FIND_PACKAGE(Boost)
FIND_PACKAGE(Boost COMPONENTS thread)
message("BOOST LIBRARY: " ${Boost_LIBRARY_DIRS})
message("Boost LIBRARIES: " ${Boost_LIBRARIES})
message("LIBS : " ${LIBS})
IF(Boost_FOUND)
message("Boost include directory is found")
message("Boost_INCLUDE_DIRS: "${Boost_INCLUDE_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
add_executable(main main.cpp)
target_link_libraries( main ${Boost_LIBRARIES} )
ENDIF(Boost_FOUND)
Here is the output console:
For using the boost thread module with CMake you must do
find(Boost COMPONENTS thread)
Normaly, this add the path to the boost thread lib in Boost_LIBRARIES var.

How do I force cmake to include "-pthread" option during compilation?

I know there is something like find_package(Threads) but it doesn't seem to make a difference (at least by itself). For now I'm using SET(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-pthread"), but it doesn't look like a correct solution to me.
The Threads module in the latest versions (>= 3.1) of CMake generates the Threads::Threads imported target. Linking your target against Threads::Threads adds all the necessary compilation and linking flags. It can be done like this:
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
add_executable(test test.cpp)
target_link_libraries(test Threads::Threads)
Use of the imported target is highly recommended for new code, according to the CMake docs
find_package( Threads ) calls a CMake module that first, searches the file system for the appropriate threads package for this platform, and then sets the CMAKE_THREAD_LIBS_INIT variable (and some other variables as well). It does not tell CMake to link any executables against whatever threads library it finds. You tell CMake to link you executable against the "Threads" library with the target_link_libraries() command. So, for example lets say your program is called test. To link it against threads you need to:
find_package( Threads )
add_executable( test test.cpp )
target_link_libraries( test ${CMAKE_THREAD_LIBS_INIT} )
How about the following:
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
if(CMAKE_USE_PTHREADS_INIT)
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-pthread")
elseif(...)
...
endif()
add_executable( test test.cpp )
target_link_libraries( test ${CMAKE_THREAD_LIBS_INIT} )
If I explicitly specify the default entry point and the library to use, it compiles without problems. The default entry point here is to specify the version in cmake.
cmake_minimum_required(...), target_link_libraries(...)
Below is an example.
# important
cmake_minimum_required(VERSION 2.8)
project(main)
# set c++ version & etc...
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# important
find_package( Threads )
add_executable(main main.cpp)
# important
target_link_libraries(main ${CMAKE_THREAD_LIBS_INIT})

Resources