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?
Related
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 )
.........
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.
I'm attempting to add OpenMP to a project that is building with CMake. I'm having no problem building it on Linux with the standard CMake/OpenMP addition:
find_package(OpenMP)
if (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()
Unfortunately this doesn't seem to work on macOS targets. When cmake is called, the following error is given:
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS)
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
I'm using macOS High Sierra (10.13.3) along with CMake 3.11. I've installed OpenMP 5.01 via brew, 'brew install libomp'. I've found some previous posts commenting on issues regarding these three but they all seem to deal with a previous way of installing OpenMP on macOS, "brew install clang-omp".
I'm thinking this might have something to do with CMake not support this OpenMP install as I'm able to use OpenMP no problem with standard makefiles. Any information provided would be much appreciated.
I've been able to answer my own question (apologies for not figuring this out beforehand, hopefully this can help others with the same issue).
It seems that a patch has been submitted to CMake to allow it to properly create buildsystems with the new OpenMP install: https://gitlab.kitware.com/cmake/cmake/merge_requests/1812
For others seeing this in the future, update to CMake 3.12 if it has been released at the time of reading.
I had the same problem and it took one complete day to find the solution. I am using Mac-Sierra 10.13.4. I want to use Opencv3 (I think the same problem also appears for opencv2) and openMP. I was actually using Clion as the IDE (CLion uses cmake to configure the project unlike other IDE), so I have to write the CMakeLists.txt file.
There was a conflict of using gcc as the compiler for openCV and openMP. If you use gcc as the compiler then it gives error for opencv as :
imwrite() on OS X error: Undefined symbols
You need to specifically use llvm compiler on OS X to resolve this issue. Following, I am giving the correct code for using OpenCV and OpenMP on Mac-Sierra:
cmake_minimum_required(VERSION 3.10)
project(MyOpenCVTest)
set(CMAKE_CXX_STANDARD 11)
add_executable(MyOpenCVTest main.cpp)
# set("OpenCV_DIR" "/modules/opencv/3.4.1/share/OpenCV/")
set(CMAKE_PREFIX_PATH "/usr/local/Cellar/opencv#3/")
set(OpenCV_INCLUDE_DIRS "/usr/local/Cellar/opencv#3/include/")
set(OpenCV_LIBS "/usr/local/Cellar/opencv#3/lib/")
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}")
if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++0x")
endif()
set(CMAKE_C_COMPILER "/usr/local/Cellar/llvm/6.0.0/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/local/Cellar/llvm/6.0.0/bin/clang++")
set(OPENMP_LIBRARIES "/usr/local/Cellar/llvm/6.0.0/lib")
set(OPENMP_INCLUDES "/usr/local/Cellar/llvm/6.0.0/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 "${CMAKE_C_COMPILER}")
set(OpenMP_C_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
set(OpenMP_C_LIB_NAMES "libomp" "libgomp" "libiomp5")
set(OpenMP_libomp_LIBRARY ${OpenMP_C_LIB_NAMES})
set(OpenMP_libgomp_LIBRARY ${OpenMP_C_LIB_NAMES})
set(OpenMP_libiomp5_LIBRARY ${OpenMP_C_LIB_NAMES})
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
set(OpenMP_CXX_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
set(OpenMP_CXX_LIB_NAMES "libomp" "libgomp" "libiomp5")
set(OpenMP_libomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
set(OpenMP_libiomp5_LIBRARY ${OpenMP_CXX_LIB_NAMES})
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}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
# set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif(OPENMP_FOUND)
include_directories( ${OpenCV_INCLUDE_DIRS} )
target_link_libraries( MyOpenCVTest ${OpenCV_LIBS})
TARGET_LINK_LIBRARIES(MyOpenCVTest opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs)
You might want to set e.g. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lpthread") such that the linker automatically detects the appropriate pthread library
Do
brew reinstall llvm
to install llvm compiler.
Please note that, you can't use gcc compiler on Mac-Sierra for your project which needs openMP and also openCV. You need to use llvm compiler.
Verify the correct location of llvm and openCV installation directory.
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)
I'm trying to get mlpack-2.0.1 to work on Visual Studio 14 2015 (I'm using Windows) but have had no success and I've been trying for hours but keep getting the same error: "No C++11 compiler available!" Additionally, I've read a handful of other similar issues on Stack Exchange and none have done the trick. I'm confused because I've been using VS 2015 for months without any errors. Is it possible I changed some compiler setting there and didn't even know it? Should I uninstall visual studio and reinstall it? I've downloaded CMake 3.5.2 and its directory is (the .exe is in the \bin subfolder):
C:\Program Files (x86)\CMake\
The CMakeLists.txt file for mlpack-2.0.1 is found in:
C:\Users\owner\Desktop\C++\
I've used the CMake GUI and command prompt to try to get this to work but have been unable to do the job. I'm not all that sophisticated with changing CMake code so any help would be appreciated. Does anyone know what to do?
You have problem with mlpack:
cmake_minimum_required(VERSION 2.8.5)
project(mlpack C CXX)
# Ensure that we have a C++11 compiler.
include(CMake/CXX11.cmake)
check_for_cxx11_compiler(HAS_CXX11)
if(NOT HAS_CXX11)
message(FATAL_ERROR "No C++11 compiler available!")
endif(NOT HAS_CXX11)
enable_cxx11()
especially with CMake/CXX11.cmake:
macro(check_for_cxx11_compiler _VAR)
message(STATUS "Checking for C++11 compiler")
set(${_VAR})
if((MSVC AND (MSVC10 OR MSVC11 OR MSVC12)) OR
(CMAKE_COMPILER_IS_GNUCXX AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.6) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.1) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 12.0))
set(${_VAR} 1)
message(STATUS "Checking for C++11 compiler - available")
else()
message(STATUS "Checking for C++11 compiler - unavailable")
endif()
endmacro()
So you have to add MSVC14 to condition:
macro(check_for_cxx11_compiler _VAR)
message(STATUS "Checking for C++11 compiler")
set(${_VAR})
if((MSVC AND (MSVC10 OR MSVC11 OR MSVC12 OR MSVC13 OR MSVC14)) OR
(CMAKE_COMPILER_IS_GNUCXX AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.6) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.1) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 12.0))
set(${_VAR} 1)
message(STATUS "Checking for C++11 compiler - available")
else()
message(STATUS "Checking for C++11 compiler - unavailable")
endif()
endmacro()
Try this.