I am clueless as to why the following CMakeLists.txt file complies but does not run. The error I am getting is:
[rosrun] Couldn't find executable named main_GUI1 below /home/jay/fuerte/sandbox/tum_ardrone
My CMakeLists.txt is (sorry to include it all but its the best way I think):
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
# Set the build type. Options are:
# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage
# Debug : w/ debug symbols, w/o optimization
# Release : w/o debug symbols, w/ optimization
# RelWithDebInfo : w/ debug symbols, w/ optimization
# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries
set(ROS_BUILD_TYPE RelWithDebInfo)
rosbuild_init()
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
# ------------------- add dynamic reconfigure api ------------------------------------
rosbuild_find_ros_package(dynamic_reconfigure)
include(${dynamic_reconfigure_PACKAGE_PATH}/cmake/cfgbuild.cmake)
gencfg()
# ------------------- add common files ------------------------------------
set(COMMON_SOURCE_FILES
src/UINode/tum_ardrone_gui.cpp
src/UINode/RosThread.cpp
src/UINode/PingThread.cpp
)
set(COMMON_HEADER_FILES
src/UINode/tum_ardrone_gui.h
src/UINode/RosThread.h
src/UINode/PingThread.h
)
#------------------set required libs and headers---------------------------
include_directories(
${PROJECT_SOURCE_DIR}/thirdparty/TooN/include
${PROJECT_SOURCE_DIR}/thirdparty/libcvd/include
${PROJECT_SOURCE_DIR}/thirdparty/gvars3/include
)
link_directories(
${PROJECT_SOURCE_DIR}/thirdparty/libcvd/lib
${PROJECT_SOURCE_DIR}/thirdparty/gvars3/lib
)
# ---------------------------- TEST --------------------------------------------------
# set header and source files
set(GUIA_SOURCE_FILES
${COMMON_SOURCE_FILES}
src/commands/main_GUI1.cpp
)
set(GUIA_HEADER_FILES
${COMMON_HEADER_FILES}
src/pathplanning/AStarAlgorithm.h
)
# *.ui
set(GUIA_UI_FILES
src/UINode/tum_ardrone_gui.ui
)
# *.qrc
set(GUIA_RESOURCE_FILES
)
# do QT stuff
ADD_DEFINITIONS( -Wall ) #this is fine
find_package(Qt4 REQUIRED) #this is fine
include(${QT_USE_FILE}) #this is fine
QT4_ADD_RESOURCES(GUIA_RESOURCE_FILES_CPP ${GUIA_RESOURCE_FILES}) #this is fine
QT4_WRAP_UI(GUIA_UI_FILES_HPP ${GUIA_UI_FILES}) #this is fine
QT4_WRAP_CPP(GUIA_HEADER_FILES_HPP ${GUIA_HEADER_FILES}) #error goes if i remove include_directories(${CMAKE_CURRENT_BINARY_DIR}) above
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# build!
rosbuild_add_executable(main_GUI1 ${GUIA_SOURCE_FILES} ${GUIA_RESOURCE_FILES_CPP} ${GUIA_UI_FILES_HPP} ${GUIA_HEADER_FILES_HPP})
target_link_libraries(main_GUI1 ${QT_LIBRARIES} cvd)
# ---------------------------- Messages & Services --------------------------------------------------
#uncomment if you have defined messages
rosbuild_genmsg()
#uncomment if you have defined services
rosbuild_gensrv()
I have the main_GUI1.cpp in src/commands so I do not know why I am getting this error. Thanks in advance!
Related
I have a conanfile describing what I want to include (in this case, mainly the OpenCV part), and a corresponding cmakelists going with it. When running conan install and then cmake, it works, but during compilation the OpenCV libraries could not be included. The same code works on windows, so I wonder if I forgot some setting or so.
The include files appear to be found, but when it comes to linking:
`undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)''
Conanfile.py:
from conans import ConanFile, CMake
from conans import tools
from conans.tools import os_info, SystemPackageTool
import os, sys
import sysconfig
from io import StringIO
class PadConan(ConanFile):
name = "AmbuScan"
version = "0.1.0"
description = "AmbuScan for pad localization"
url = ""
license = "GPL"
short_paths = True
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
ubitrack_version = "1.3.0"
requires = (
"opencv/4.3.0#conan/stable",
"kinect-azure-sensor-sdk/1.4.1#camposs/stable",
"zlib/1.2.11#camposs/stable",
)
# all sources are deployed with the package
exports_sources = "include/*", "src/*", "CMakeLists.txt"
def system_requirements(self):
pass
def configure(self):
self.options['opencv'].contrib = False
self.options['opencv'].cuda = False
def imports(self):
self.copy(src="bin", pattern="*.dll", dst="./bin") # Copies all dll files from packages bin folder to my "bin" folder
self.copy(src="", pattern="**.dll", dst="./bin", keep_path=False) # Copies all dll files from packages bin folder to my "bin" folder
self.copy(src="lib", pattern="*.lib", dst="./lib") # Copies all lib files from packages lib folder to my "lib" folder
self.copy(src="bin", pattern="*", dst="./bin") # Copies all applications
self.copy(src="bin", pattern="*.dll", dst="./bin") # Copies all dll files from packages bin folder to my "bin" folder
self.copy(src="lib", pattern="*.dylib*", dst="./lib") # Copies all dylib files from packages lib folder to my "lib" folder
self.copy(src="lib", pattern="*.so*", dst="./lib") # Copies all so files from packages lib folder to my "lib" folder
self.copy(src="lib", pattern="*.a", dst="./lib") # Copies all static libraries from packages lib folder to my "lib" folder
def _configure_cmake(self):
cmake = CMake(self)
cmake.verbose = True
def add_cmake_option(option, value):
var_name = "{}".format(option).upper()
value_str = "{}".format(value)
var_value = "ON" if value_str == 'True' else "OFF" if value_str == 'False' else value_str
cmake.definitions[var_name] = var_value
for option, value in self.options.items():
add_cmake_option(option, value)
cmake.configure()
return cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
def package(self):
cmake = self._configure_cmake()
cmake.install()
CMakelists.txt:
cmake_minimum_required(VERSION 3.18)
project(PadLocalizer C CXX)
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo_multi.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo_multi.cmake)
conan_set_find_paths()
elseif(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
else()
message(WARNING "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first")
endif()
conan_basic_setup(TARGETS)
include(GNUInstallDirs)
if(UNIX)
if(APPLE)
MESSAGE(STATUS "Building for Macos.")
set(PAD_TARGET_APPLE 1)
endif()
MESSAGE(STATUS "Building for Unix.")
set(PAD_TARGET_UNIX 1)
elseif(WIN32)
MESSAGE(STATUS "Building for Windows.")
set(PAD_TARGET_WINDOWS 1)
endif()
if (MSVC)
# per default disable extended aligned storage for now on msvc
add_definitions(-D_DISABLE_EXTENDED_ALIGNED_STORAGE -DHAVE_SNPRINTF)
endif()
set(PAD_HEADERS
"include/runtime.h"
)
set(PAD_HEADERS_CAPTURE
"include/azure_camera.h"
)
set(PAD_SOURCES
src/main.cpp
)
set(PAD_SOURCES_CAPTURE
src/azure_camera.cpp
)
source_group(pad\\include FILES ${PAD_HEADERS})
source_group(pad\\include\\capture FILES ${PAD_HEADERS_CAPTURE})
source_group(pad\\src FILES ${PAD_SOURCES})
source_group(pad\\src\\capture FILES ${PAD_SOURCES_CAPTURE})
add_executable(pad
${PAD_SOURCES}
${PAD_HEADERS}
${PAD_SOURCES_CAPTURE}
${PAD_HEADERS_CAPTURE}
)
set_target_properties(pad PROPERTIES CXX_STANDARD 17)
set_target_properties(pad PROPERTIES LINKER_LANGUAGE CXX)
set_property(TARGET pad PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(pad PUBLIC
CONAN_PKG::opencv
CONAN_PKG::eigen
CONAN_PKG::kinect-azure-sensor-sdk
)
target_include_directories(pad PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>/include
$<INSTALL_INTERFACE:include>
PRIVATE
${PROJECT_BINARY_DIR}/include
${PROJECT_BINARY_DIR}/src
${PROJECT_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/include
)
# need to review these settings if they are still appropriate
MESSAGE(STATUS "Building for ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}")
if(WIN32)
set_target_properties(pad PROPERTIES COMPILE_FLAGS "/EHsc /c /W3 /GR /wd4355 /wd4996 /wd4251 /wd4275 /wd4819 /wd4290")
set_target_properties(pad PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
set_target_properties(pad PROPERTIES COMPILE_DEFINITIONS "WIN32" "_MBCS" "BOOST_SPIRIT_USE_OLD_NAMESPACE")
set_target_properties(pad PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib")
## Check for Windows Version ##
if( ${CMAKE_SYSTEM_VERSION} EQUAL 6.1 ) # Windows 7
MESSAGE(STATUS "Setting minimum Windows version to Win7 WINVER=0x0601")
set_target_properties(pad PROPERTIES COMPILE_DEFINITIONS WINVER=0x0601)
elseif( ${CMAKE_SYSTEM_VERSION} EQUAL 6.2 ) # Windows 8
MESSAGE(STATUS "Setting minimum Windows version to Win8 WINVER=0x0602")
set_target_properties(pad PROPERTIES COMPILE_DEFINITIONS WINVER=0x0602)
elseif( ${CMAKE_SYSTEM_VERSION} EQUAL 6.3 ) # Windows 8.1
MESSAGE(STATUS "Setting minimum Windows version to Win8.1 WINVER=0x0603")
set_target_properties(pad PROPERTIES COMPILE_DEFINITIONS WINVER=0x0603)
elseif( ${CMAKE_SYSTEM_VERSION} EQUAL 10.0 ) # Windows 10
MESSAGE(STATUS "Setting minimum Windows version to Win8.1 WINVER=0x0603")
set_target_properties(pad PROPERTIES COMPILE_DEFINITIONS WINVER=0x0603)
else() # Some other Windows
MESSAGE(STATUS "Setting minimum Windows version to Vista WINVER=0x0600")
set_target_properties(pad PROPERTIES COMPILE_DEFINITIONS WINVER=0x0600)
endif()
endif(WIN32)
install(TARGETS pad EXPORT padConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) # This is for Windows
# This makes the project importable from the install directory
# Put config file in per-project dir (name MUST match), can also
# just go into 'cmake'.
install(EXPORT padConfig DESTINATION share/pad/cmake)
# This makes the project importable from the build directory
export(TARGETS pad FILE padConfig.cmake)
Which OS and compiler do you use? What are your conan settings? Type:
conan profile show default
If "default" is your default profile of course.
If you use compiler gcc > 5, please make sure you use the c++11 ABI:
conan profile update settings.compiler.libcxx=libstdc++11 default
See output of pkg-config opencv --libs to find out what libraries you're missing.
Then add them to your config.
I'm trying to add sound and music to my openGL project. I'm using Cmake. I get undefined reference errors and have tried for days using many methods and suggestions I've read about, but I am over my head apparently.
I have installed the libraries that I think are needed, I have configured and make installed, tried, finding the packages, added module code to help facilitate it. I am somewhat aware not all of these methods are likely useful in my case. Or maybe I need to have these libraries in my project folder and on my system ...installed. Ok, not super clear about that. I am using Ubuntu Linux with codeblocks to edit my scripts, but not to compile.
My cmakelists.text
cmake_minimum_required (VERSION 3.0)
project (maficengine LANGUAGES C CXX ASM)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/external/")
find_package(OpenGL REQUIRED)
#FIND_PACKAGE(SDL2_MIXER)
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS})
#target_link_libraries(maficengine ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
find_file(SDL2_INCLUDE_DIR NAME SDL.h HINTS SDL2)
find_library(SDL2_LIBRARY NAME SDL2)
set(SDL2_INCLUDE_DIR /usr/include/SDL2)
set(SDL2_LIBRARY /usr/lib/x86_64-linux-gnu/libSDL2.so)
#file(GLOB_RECURSE SOURCE_FILES/usr/lib/x86_64-linux-gnu
# ${CMAKE_SOURCE_DIR}/src/*.c
# ${CMAKE_SOURCE_DIR}/src/*.cpp)
INCLUDE(FindPkgConfig)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
PKG_SEARCH_MODULE(SDL REQUIRED sdl)
set(SDL_INCLUDE_DIR "/usr/include/SDL2")
set(SDL_LIBRARY "SDL2")
include(FindSDL)
if(SDL_FOUND)
message(STATUS "SDL FOUND")
elseif(!SDL_FOUND)
message(STATUS "SDL not FOUND")
endif()
find_library(SDL_MIXER_LIBRARY
NAMES SDL2_mixer
HINTS
ENV SDLMIXERDIR
ENV SDLDIR
PATH_SUFFIXES lib
)
if( CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR )
message( FATAL_ERROR "Please select another Build Directory ! (and give it a clever name, like bin_Visual2012_64bits/)" )
endif()
if( CMAKE_SOURCE_DIR MATCHES " " )
message( "Your Source Directory contains spaces. If you experience problems when compiling, this can be the cause." )
endif()
if( CMAKE_BINARY_DIR MATCHES " " )
message( "Your Build Directory contains spaces. If you experience problems when compiling, this can be the cause." )
endif()
file(GLOB SOURCES "external/myCustomHeaders/*.cpp")
add_library(loaders SHARED ${SOURCES}
${SDL2_INCLUDE_DIR}
external/SDL2_image-2.0.4/SDL_image.h
external/myCustomHeaders/include/loadTexture.h
external/myCustomHeaders/loadTexture.cpp
/usr/include/SDL2/SDL.h
/usr/include/SDL/SDL_image.h
external/SDL2_mixer-2.0.4/SDL_mixer.h
)
include_directories( external/myCustomHeaders/include )
include_directories( external/SDL2_mixer-2.0.4/acinclude )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}external/SDL2_mixer-2.0.4 )
include_directories(/usr/include/SDL2)
include_directories(/usr/include/SDL)
include_directories(${SDL2_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
find_path(
SDL_MIXER_INCLUDE_DIR
PATHS
/usr/include/SDL
/usr/include/SDL2
/usr/include
/usr/local/include
/sw/include
/opt/local/include
${SDL_MIXER_ROOT_DIR}/include
DOC "The directory where SDL_mixer.h resides")
link_directories(external/myCustomHeaders/include)
link_directories(external/myCustomHeaders)
link_directories(external/SDL2_mixer-2.0.4)
link_directories(/usr/include/SDL2)
link_directories(/usr/include/SDL)
# Compile external dependencies
add_subdirectory (external)
# On Visual 2005 and above, this module can set the debug working directory
cmake_policy(SET CMP0026 OLD)
cmake_policy(SET CMP0079 NEW)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/rpavlik-cmake-modules-fe2273")
include(CreateLaunchers)
include(MSVCMultipleProcessCompile) # /MP
if(INCLUDE_DISTRIB)
add_subdirectory(distrib)
endif(INCLUDE_DISTRIB)
include_directories(
external/AntTweakBar-1.16/include/
external/glfw-3.1.2/include/
external/glm-0.9.7.1/
external/glew-1.13.0/include/
external/assimp-3.0.1270/include/
external/bullet-2.81-rev2613/src/
external/myCustomHeaders/include
common/
)
set(ALL_LIBS
${OPENGL_LIBRARY}
glfw
GLEW_1130
loaders
)
add_definitions(
-DTW_STATIC
-DTW_NO_LIB_PRAGMA
-DTW_NO_DIRECT3D
-DGLEW_STATIC
-D_CRT_SECURE_NO_WARNINGS
)
# Tutorial 17
add_executable(mageengine
${SDL2_LIBRARY}
Mafic/mafic.cpp
common/shader.cpp
common/shader.hpp
common/controls.cpp
common/controls.hpp
common/texture.cpp
common/texture.hpp
common/objloader.cpp
common/objloader.hpp
common/vboindexer.cpp
common/vboindexer.hpp
common/quaternion_utils.cpp
common/quaternion_utils.hpp
Mafic/StandardShading.vertexshader
Mafic/StandardShading.fragmentshader
)
set_target_properties(loaders
PROPERTIES LINKER_LANGUAGE CXX)
#target_sources(loaders
# PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/myCustomHeaders/loadTexture.h
# )
target_link_libraries(mageengine
${ALL_LIBS}
ANTTWEAKBAR_116_OGLCORE_GLFW
${SDL2_LIBRARIES}
loaders
)
#target_link_libraries(${maficengine } SDL2::Main SDL2::Image)
# Xcode and Visual working directories
set_target_properties(mageengine PROPERTIES XCODE_ATTRIBUTE_CONFIGURATION_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Mafic/")
create_target_launcher(mageengine WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Mafic/")
SOURCE_GROUP(common REGULAR_EXPRESSION ".*/common/.*" )
SOURCE_GROUP(shaders REGULAR_EXPRESSION ".*/.*shader$" )
if (NOT ${CMAKE_GENERATOR} MATCHES "Xcode" )
add_custom_command(
TARGET mageengine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/mageengine${CMAKE_EXECUTABLE_SUFFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/Mafic/"
)
#target_link_libraries(mageengine LINK_PUBLIC ${mylibrary}
# )
elseif (${CMAKE_GENERATOR} MATCHES "Xcode" )
endif (NOT ${CMAKE_GENERATOR} MATCHES "Xcode" )
this is my module code that I'm using, I assume its possibly being used by cmake
# Locate SDL_image library
#
# This module defines:
#
# ::
#
# SDL2_IMAGE_LIBRARIES, the name of the library to link against
# SDL2_IMAGE_INCLUDE_DIRS, where to find the headers
# SDL2_IMAGE_FOUND, if false, do not try to link against
# SDL2_IMAGE_VERSION_STRING - human-readable string containing the version of SDL_image
#
#
#
# For backward compatibility the following variables are also set:
#
# ::
#
# SDLIMAGE_LIBRARY (same value as SDL2_IMAGE_LIBRARIES)
# SDLIMAGE_INCLUDE_DIR (same value as SDL2_IMAGE_INCLUDE_DIRS)
# SDLIMAGE_FOUND (same value as SDL2_IMAGE_FOUND)
#
#
#
# $SDLDIR is an environment variable that would correspond to the
# ./configure --prefix=$SDLDIR used in building SDL.
#
# Created by Eric Wing. This was influenced by the FindSDL.cmake
# module, but with modifications to recognize OS X frameworks and
# additional Unix paths (FreeBSD, etc).
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
# Copyright 2012 Benjamin Eikel
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
find_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h
HINTS
ENV SDL2IMAGEDIR
ENV SDL2DIR
PATH_SUFFIXES SDL2
# path suffixes to search inside ENV{SDLDIR}
include/SDL2 include
PATHS ${SDL2_IMAGE_PATH}
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(VC_LIB_PATH_SUFFIX lib/x64)
else()
set(VC_LIB_PATH_SUFFIX lib/x86)
endif()
find_library(SDL2_IMAGE_LIBRARY
NAMES SDL2_image
HINTS
ENV SDL2IMAGEDIR
ENV SDL2DIR
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
PATHS ${SDL2_IMAGE_PATH}
)
if(SDL2_IMAGE_INCLUDE_DIR AND EXISTS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h")
file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+[0-9]+$")
file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+[0-9]+$")
file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+[0-9]+$")
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MAJOR "${SDL2_IMAGE_VERSION_MAJOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MINOR "${SDL2_IMAGE_VERSION_MINOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_PATCH "${SDL2_IMAGE_VERSION_PATCH_LINE}")
set(SDL2_IMAGE_VERSION_STRING ${SDL2_IMAGE_VERSION_MAJOR}.${SDL2_IMAGE_VERSION_MINOR}.${SDL2_IMAGE_VERSION_PATCH})
unset(SDL2_IMAGE_VERSION_MAJOR_LINE)
unset(SDL2_IMAGE_VERSION_MINOR_LINE)
unset(SDL2_IMAGE_VERSION_PATCH_LINE)
unset(SDL2_IMAGE_VERSION_MAJOR)
unset(SDL2_IMAGE_VERSION_MINOR)
unset(SDL2_IMAGE_VERSION_PATCH)
endif()
set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY})
set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image
REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS
VERSION_VAR SDL2_IMAGE_VERSION_STRING)
# for backward compatibility
set(SDLIMAGE_LIBRARY ${SDL2_IMAGE_LIBRARIES})
set(SDLIMAGE_INCLUDE_DIR ${SDL2_IMAGE_INCLUDE_DIRS})
set(SDLIMAGE_FOUND ${SDL2_IMAGE_FOUND})
mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR)
My Cmake error output, I am a beginner with cmake btw, so laugh all you will.
CMakeFiles/mageengine.dir/Mafic/mafic.cpp.o: In function `load_image(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
mafic.cpp:(.text+0x2c): undefined reference to `IMG_Load'
mafic.cpp:(.text+0x43): undefined reference to `SDL_DisplayFormat'
CMakeFiles/mageengine.dir/Mafic/mafic.cpp.o: In function `init()':
mafic.cpp:(.text+0x133): undefined reference to `SDL_SetVideoMode'
mafic.cpp:(.text+0x152): undefined reference to `TTF_Init'
mafic.cpp:(.text+0x17c): undefined reference to `Mix_OpenAudio'
mafic.cpp:(.text+0x19e): undefined reference to `SDL_WM_SetCaption'
CMakeFiles/mageengine.dir/Mafic/mafic.cpp.o: In function `load_files()':
mafic.cpp:(.text+0x21c): undefined reference to `TTF_OpenFont'
mafic.cpp:(.text+0x25b): undefined reference to `Mix_LoadMUS'
mafic.cpp:(.text+0x298): undefined reference to `Mix_LoadWAV_RW'
mafic.cpp:(.text+0x2bf): undefined reference to `Mix_LoadWAV_RW'
mafic.cpp:(.text+0x2e6): undefined reference to `Mix_LoadWAV_RW'
mafic.cpp:(.text+0x30d): undefined reference to `Mix_LoadWAV_RW'
CMakeFiles/mageengine.dir/Mafic/mafic.cpp.o: In function `clean_up()':
mafic.cpp:(.text+0x3ba): undefined reference to `Mix_FreeChunk'
mafic.cpp:(.text+0x3c9): undefined reference to `Mix_FreeChunk'
mafic.cpp:(.text+0x3d8): undefined reference to `Mix_FreeChunk'
mafic.cpp:(.text+0x3e7): undefined reference to `Mix_FreeChunk'
mafic.cpp:(.text+0x3f6): undefined reference to `Mix_FreeMusic'
mafic.cpp:(.text+0x405): undefined reference to `TTF_CloseFont'
mafic.cpp:(.text+0x40a): undefined reference to `Mix_CloseAudio'
mafic.cpp:(.text+0x40f): undefined reference to `TTF_Quit'
collect2: error: ld returned 1 exit status
CMakeFiles/mageengine.dir/build.make:197: recipe for target 'mageengine' failed
make[2]: *** [mageengine] Error 1
CMakeFiles/Makefile2:75: recipe for target 'CMakeFiles/mageengine.dir/all' failed
make[1]: *** [CMakeFiles/mageengine.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
Ok, I seem to have worked out the kinks. A magnitude harder than I led myself and others to believe.. - Probably did it the wrong way, but doesn't seem like many are going about it the way I am. I just went through and linked the libraries in my cmake file by doing this target_link_libraries(loaders -lSDLmain) target_link_libraries(loaders -lSDL) target_link_libraries(loaders -lSDL2_ttf) target_link_libraries(loaders -lSDL2_mixer) and downloading and istalling libs as needed. All this being said, i still have many problems, but i think it's a step closer.
I want to build my project in catkin workspace. After executing catkin_make i got these errors:
6:11: error: ‘vector’ is not a member of ‘cv’
cv::vector<cv::Point> points;
6:31: error: expected primary-expression before ‘>’ token
cv::vector<cv::Point> points;
9:77: error: no matching function for call to ‘std::vector<Eigen::Matrix<double, 3, 1>, Eigen::aligned_allocator<Eigen::Matrix<double, 3, 1> > >::push_back(cv::Point)’
/catkin_ws/src/rgbd_calibration/src/rgbd_calibration/calibration_test.cpp:1123:113: error: no matching function for call to ‘fillConvexPoly(cv::Mat&, std::vector<Eigen::Matrix<double, 3, 1>, Eigen::aligned_allocator<Eigen::Matrix<double, 3, 1> > >&, cv::Scalar)’
cv::fillConvexPoly(tmp_image, points, cv::Scalar(c == 0 ? 128 : 0, c == 1 ? 128 : 0, c == 2 ? 128 : 0));
^
In file included from /opt/ros/kinetic/include/opencv-3.3.1-dev/opencv2/imgproc/imgproc.hpp:48:0,
from /opt/ros/kinetic/include/image_geometry/pinhole_camera_model.h:6,
I have build opencv 3.3.0, and also it finds `/opt/ros/kinetic/include/opencv-3.3.1-dev/opencv2/imgproc/imgproc.hpp:48:0,
I suspect that somthing has to do with opencv library but cant find out. Its my first try with ROS so any help would be welcomed
Makefile below:
cmake_minimum_required(VERSION 2.8.3)
project(rgbd_calibration)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS cmake_modules roscpp calibration_common geometry_msgs kinect
eigen_conversions camera_info_manager cv_bridge pcl_ros
image_transport)# swissranger_camera)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
find_package(Boost REQUIRED)
find_package(Eigen REQUIRED)
find_package(PCL 1.7 REQUIRED)
find_package(OpenCV REQUIRED)
find_package(OpenMP REQUIRED)
find_package(Ceres REQUIRED)
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}")
## Uncomment this if the package has a setup.py. This macro ensures
## modules and scripts declared therein get installed
# catkin_python_setup()
#######################################
## Declare ROS messages and services ##
#######################################
## Generate messages in the 'msg' folder
add_message_files(
FILES
Acquisition.msg
)
## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
std_msgs
)
###################################################
## Declare things to be passed to other projects ##
###################################################
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
INCLUDE_DIRS include
LIBRARIES interactive_checkerboard_finder rgbd_calibration
CATKIN_DEPENDS roscpp calibration_common geometry_msgs kinect
eigen_conversions camera_info_manager cv_bridge pcl_ros image_transport
DEPENDS eigen3 pcl opencv2
)
###########
## Build ##
###########
## Specify additional locations of header files
include_directories(include
${catkin_INCLUDE_DIRS}
${EIGEN_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
${CERES_INCLUDE_DIRS}
)
## Declare a cpp library
add_library(rgbd_calibration
src/rgbd_calibration/calibration.cpp include/rgbd_calibration/calibration.h
include/rgbd_calibration/globals.h
src/rgbd_calibration/depth_undistortion_estimation.cpp include/rgbd_calibration/depth_undistortion_estimation.h
src/rgbd_calibration/checkerboard_views.cpp include/rgbd_calibration/checkerboard_views.h
src/rgbd_calibration/checkerboard_views_extractor.cpp include/rgbd_calibration/checkerboard_views_extractor.h
src/rgbd_calibration/publisher.cpp include/rgbd_calibration/publisher.h
)
add_executable(rgbd_offline_calibration
src/rgbd_calibration/calibration_node.cpp include/rgbd_calibration/calibration_node.h
src/rgbd_calibration/offline_calibration_node.cpp include/rgbd_calibration/offline_calibration_node.h
)
#add_executable(simulation
# src/rgbd_calibration/simulation_node.cpp include/rgbd_calibration/simulation_node.h
#)
add_executable(test_calibration
src/rgbd_calibration/test_node.cpp include/rgbd_calibration/test_node.h
src/rgbd_calibration/calibration_test.cpp include/rgbd_calibration/calibration_test.h
)
add_executable(data_collection
src/rgbd_calibration/data_collection_node.cpp
)
## Add dependencies to the executable
# add_dependencies(calibration_node ${PROJECT_NAME})
## Specify libraries to link a library or executable target against
target_link_libraries(rgbd_calibration
${catkin_LIBRARIES}
${PCL_LIBRARIES}
${OpenCV_LIBS}
${CERES_LIBRARIES}
)
target_link_libraries(rgbd_offline_calibration
rgbd_calibration
${catkin_LIBRARIES}
${PCL_LIBRARIES}
${OpenCV_LIBS}
${CERES_LIBRARIES}
)
#target_link_libraries(simulation
# rgbd_calibration
# ${catkin_LIBRARIES}
# ${PCL_LIBRARIES}
# ${OpenCV_LIBS}
# ${CERES_LIBRARIES}
#)
target_link_libraries(test_calibration
rgbd_calibration
${catkin_LIBRARIES}
${PCL_LIBRARIES}
${OpenCV_LIBS}
${CERES_LIBRARIES}
)
target_link_libraries(data_collection
${catkin_LIBRARIES}
${PCL_LIBRARIES}
${OpenCV_LIBS}
)
#############
## Install ##
#############
## Mark executable scripts (Python etc.) for installation
## not required for python when using catkin_python_setup()
# install(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark executables and/or libraries for installation
# install(TARGETS calibration calibration_node
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )
## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )
#############
## Testing ##
#############
## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/polynomial_undistortion_matrix_multifit_test.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test
# ${catkin_LIBRARIES}
# ${PCL_LIBRARIES}
# ${OpenCV_LIBS}
# ${CERES_LIBRARIES})
# endif()
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
You need to use STL's std::vector<>, CV does not have a vector implementation:
#include <vector>
...
std::vector<cv::Point> points;
...
I have the following cmake file to download, build and install zlib:
cmake_minimum_required ( VERSION 2.8.7 )
include (ExternalProject)
if(UNIX)
# An external project for zlib
SET (GIT_URL https://github.com/madler/zlib.git)
SET (ZLIB_INSTALL ${CMAKE_CURRENT_BINARY_DIR})
SET (ZLIB_INCLUDE ${CMAKE_BINARY_DIR}/include/zlib)
SET (ZLIB_STATIC ${CMAKE_BINARY_DIR}/lib/libz.a )
ExternalProject_Add(zlib
PREFIX zlib
GIT_REPOSITORY ${GIT_URL}
INSTALL_DIR ${ZLIB_INSTALL}
PATCH_COMMAND ${CMAKE_COMMAND} -E remove <SOURCE_DIR>/zconf.h
BUILD_IN_SOURCE 1
PATCH_COMMAND ""
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --includedir=${ZLIB_INCLUDE}
)
SET (ZLIB_INCLUDE_DIR ${ZLIB_INSTALL}/include/zlib)
SET (ZLIB_LIBRARY "${ZLIB_INSTALL}")
ADD_LIBRARY (ZLIB_LIB STATIC IMPORTED DEPENDS zlib)
SET_TARGET_PROPERTIES (ZLIB_LIB PROPERTIES IMPORTED_LOCATION "${ZLIB_STATIC}")
endif(UNIX)
But this cmake file only install zlib. I want also install minizip. Minizip is "part of zlib". In the zlib repository has a directory that has minizip.
How can I also install minizip in the same cmake file? Is it possible?
The minizip is inside zlib repository:
- zlib
- contrib
- minizip
- ....
- ...
- ...
I have cmake file to install minizip:
cmake_minimum_required(VERSION 2.8)
project(minizip)
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
set(BUILD_SHARED_LIBS OFF)
find_package (ZLIB REQUIRED)
if (ZLIB_FOUND)
set(ZLIB_LIBRARY ${CMAKE_BINARY_DIR}/ZLIB/src/ZLIB/contrib)
SET (minizip ${CMAKE_BINARY_DIR}/lib/minizip)
if(CMAKE_HOST_APPLE)
set(PLATFORM __APPLE__)
elseif(CMAKE_HOST_UNIX)
set(PLATFORM unix)
elseif(CMAKE_HOST_WIN32)
set(PLATFORM _WIN32)
else(CMAKE_HOST_APPLE)
message(FATAL_ERROR "Not supported Platform")
endif(CMAKE_HOST_APPLE)
add_definitions(-D${PLATFORM})
set(SOURCE
${ZLIB_LIBRARY}/minizip/ioapi.c
${ZLIB_LIBRARY}/minizip/miniunz.c
${ZLIB_LIBRARY}/minizip/minizip.c
${ZLIB_LIBRARY}/minizip/unzip.c
${ZLIB_LIBRARY}/minizip/zip.c
)
if(WIN32)
set(SOURCE ${SOURCE} ${ZLIB_LIBRARY}/minizip/iowin32.c)
endif(WIN32)
set(HEADERS
${ZLIB_LIBRARY}/minizip/crypt.h
${ZLIB_LIBRARY}/minizip/ioapi.h
${ZLIB_LIBRARY}/minizip/miniunz.h
${ZLIB_LIBRARY}/minizip/unzip.h
)
if(WIN32)
set(HEADERS ${HEADERS} ${ZLIB_LIBRARY}/minizip/iowin32.h)
endif(WIN32)
add_library(minizip ${SOURCE} ${HEADERS})
target_link_libraries(minizip PUBLIC "-static" ZLIB_STATIC)
add_dependencies ( minizip zlib)
install(
TARGETS minizip EXPORT minizip-exports
INCLUDES DESTINATION "include"
RUNTIME DESTINATION "bin"
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib"
)
install(
FILES ${HEADERS}
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/include/minizip"
)
ADD_LIBRARY (MINIZIP_LIB STATIC IMPORTED DEPENDS minizip)
SET_TARGET_PROPERTIES (MINIZIP_LIB PROPERTIES IMPORTED_LOCATION ${minizip})
endif()
I want before install minizip, install zlib.
But when I run
cmake ..
I have the following error:
Make Error at modules/minizip.cmake:50 (add_library):
Cannot find source file:
/home/lais/Imagens/agent/build/ZLIB/src/ZLIB/contrib/minizip/ioapi.c
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
Call Stack (most recent call first):
CMakeLists.txt:59 (include)
CMake Error: Cannot determine link language for target "minizip".
CMake Error: CMake can not determine linker language for target: minizip
And I have a top level cmake, that call for this two modules:
cmake_minimum_required( VERSION 2.8.7 )
project( project )
# version number
set ( VERSION_MAJOR 0 )
set ( VERSION_MINOR 0 )
# cpr requires c++11
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
# src : main + jsoncpp library
file ( GLOB SOURCES src/project/*.cpp )
# src : collect functions - depend on OS
if ( WIN32 )
file ( GLOB SOURCES ${SOURCES} src/project/windows/*.cpp )
else () # if( UNIX )
file ( GLOB SOURCES ${SOURCES} src/project/linux/*.cpp )
endif ()
# src : curl requests
# options for cpr
# avoid experimental use of openssl
option( CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" OFF )
# avoid building tests
option( BUILD_CPR_TESTS "Set to ON to build cpr tests." OFF )
# options for curl
# avoid building tests
option( BUILD_CURL_TESTS "Set to ON to build cURL tests." OFF )
# avoid running tests - set ON again in download version or if errors occur
option( RUN_CURL_TESTS "Set to ON to run cURL tests." OFF )
add_subdirectory ( lib/cpr )
include_directories ( ${CPR_INCLUDE_DIRS} )
include_directories ( ${CURL_INCLUDE_DIRS} )
# src : DtWinVer - Windows Version/Edition class
if ( WIN32 )
add_subdirectory ( lib/dtwinver )
endif ()
# headers
include_directories ( "include" )
include_directories ( "${CMAKE_BINARY_DIR}/include" )
# scr = libboost
include ( "modules/boost.cmake" )
# src = zlib
include ( "modules/zlib.cmake" )
# src = minizip
include ( "modules/minizip.cmake" )
# compile
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY "../bin" )
add_executable ( project-v${VERSION_MAJOR}.${VERSION_MINOR} ${SOURCES} )
target_link_libraries ( project-v${VERSION_MAJOR}.${VERSION_MINOR} ${CPR_LIBRARIES} ${CURL_LIBRARIES} ${FILESYSTEM_LIB} ${SYSTEM_LIB} ${REGEX_LIB} ${PROGRAM_OPTIONS_LIB} ${ZLIB_STATIC} ${minizip})
add_dependencies ( project-v${VERSION_MAJOR}.${VERSION_MINOR} Boost)
add_dependencies ( project-v${VERSION_MAJOR}.${VERSION_MINOR} zlib)
add_dependencies ( project-v${VERSION_MAJOR}.${VERSION_MINOR} minizip)
if ( WIN32 )
target_link_libraries ( project-v${VERSION_MAJOR}.${VERSION_MINOR} dtwinver )
else ()
# libudev
target_link_libraries ( project-v${VERSION_MAJOR}.${VERSION_MINOR} udev )
endif ()
Looks your source package is not complete.
minizip is just simple a single file minizip.c. Why do you need cmake? Just compile it and link with zlib and everything will be fine.
I'm trying to build a project using CMake 3.4.0-rc3 on 64-bit Windows 8.
When I click "generate", I get an error saying:
Thing is, when I go to C:\MinGW\bin I do have a dll called libmpc-3.dll. By looking at a similar answer I tried running mingw-get install mpc which ran successfully but didn't fix the problem. Any advice? :)
EDIT: CMakeLists.txt
#
# Root vxl
#
# vxl-maintainers#lists.sf.net
CMAKE_MINIMUM_REQUIRED(VERSION 2.5)
# Support for CMake 2.6
IF( COMMAND CMAKE_POLICY )
CMAKE_POLICY(SET CMP0003 NEW)
ENDIF( COMMAND CMAKE_POLICY )
# CMake 2.8 stuff
SET( CMAKE_LEGACY_CYGWIN_WIN32 0 ) # Remove when CMake >= 2.8.4 is required
# Use #rpath on OS X
IF( POLICY CMP0042 )
CMAKE_POLICY(SET CMP0042 NEW)
ENDIF()
PROJECT(vxl)
SET( LIBRARY_OUTPUT_PATH ${vxl_BINARY_DIR}/lib CACHE PATH
"Output directory for the vxl libraries" )
IF( NOT EXECUTABLE_OUTPUT_PATH )
SET( EXECUTABLE_OUTPUT_PATH "." )
ENDIF( NOT EXECUTABLE_OUTPUT_PATH )
# CMake support directory.
SET(VXL_CMAKE_DIR ${vxl_SOURCE_DIR}/config/cmake/Modules)
INCLUDE( ${VXL_CMAKE_DIR}/VXLStandardOptions.cmake )
INCLUDE( ${vxl_SOURCE_DIR}/config/cmake/config/vxl_utils.cmake )
# INCLUDE( ${vxl_SOURCE_DIR}/UseSTLPort.cmake )
INCLUDE(${vxl_SOURCE_DIR}/config/cmake/doxygen/doxygen.cmake)
# Copy the UseVXL.cmake file to the binary directory so that client
# projects don't need to find the source directory first. They can run
# the UseVXL.cmake from the vxl binary directory, and determine the
# vxl source directory by loading the cache.
CONFIGURE_FILE( ${VXL_CMAKE_DIR}/UseVXL.cmake
${vxl_BINARY_DIR}/UseVXL.cmake COPYONLY )
# Copy CTestCustom.cmake to top of build tree
CONFIGURE_FILE( ${VXL_CMAKE_DIR}/CTestCustom.cmake
${vxl_BINARY_DIR}/CTestCustom.cmake COPYONLY )
# Location of VXL's FindXXX.cmake CMake modules.
# This is identical to VXL_CMAKE_DIR. Perhaps we should eliminate MODULE_PATH?
SET( MODULE_PATH ${vxl_SOURCE_DIR}/config/cmake/Modules CACHE STATIC "VXL module path" )
# For use in client projects that call UseVXL.cmake
SET (VXL_LIBRARY_PATH ${LIBRARY_OUTPUT_PATH} CACHE STATIC "Where all the vxl libraries are, for clients to use." )
# Options to add extra compiler and linker flags
#
# These options allow you to specify additional flags without
# affecting the default flags for a particular platform or build type.
# This is especially useful for adding extra warning flags.
SET( VXL_EXTRA_CMAKE_C_FLAGS CACHE STRING "Extra flags appended to CMAKE_C_FLAGS" )
SET( VXL_EXTRA_CMAKE_CXX_FLAGS CACHE STRING "Extra flags appended to CMAKE_CXX_FLAGS" )
SET( VXL_EXTRA_CMAKE_EXE_LINKER_FLAGS CACHE STRING "Extra flags appended to CMAKE_EXE_LINKER_FLAGS" )
SET( VXL_EXTRA_CMAKE_MODULE_LINKER_FLAGS CACHE STRING "Extra flags appended to CMAKE_MODULE_LINKER_FLAGS" )
SET( VXL_EXTRA_CMAKE_SHARED_LINKER_FLAGS CACHE STRING "Extra flags appended to CMAKE_SHARED_LINKER_FLAGS" )
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VXL_EXTRA_CMAKE_C_FLAGS}" )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VXL_EXTRA_CMAKE_CXX_FLAGS}" )
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${VXL_EXTRA_CMAKE_EXE_LINKER_FLAGS}" )
SET( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${VXL_EXTRA_CMAKE_MODULE_LINKER_FLAGS}" )
SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${VXL_EXTRA_CMAKE_SHARED_LINKER_FLAGS}" )
# Option to specify whether this is a build for the dashboard. Each
# dashboard build should set BUILD_FOR_VXL_DASHBOARD to YES in the
# initial cache (set in the CTest script).
OPTION( BUILD_FOR_VXL_DASHBOARD "Is this a build for the dashboard?" NO )
# A variable to default some OPTIONs to YES for the dashboard, but to
# NO for other builds.
IF( BUILD_FOR_VXL_DASHBOARD )
SET( YES_FOR_DASHBOARD "YES" )
ELSE( BUILD_FOR_VXL_DASHBOARD )
SET( YES_FOR_DASHBOARD "NO" )
ENDIF( BUILD_FOR_VXL_DASHBOARD )
# Use this variable in vxl_config.h to tell if it is a shared build
set(VXL_BUILD_SHARED FALSE)
if(BUILD_SHARED_LIBS)
set(VXL_BUILD_SHARED TRUE)
endif()
# Do platform-specific configuration.
IF(NOT VXL_NO_CMAKE_CONFIGURE)
SUBDIRS(config/cmake/config)
ENDIF(NOT VXL_NO_CMAKE_CONFIGURE)
# Options to reduce build to just some core libraries
OPTION( BUILD_CORE_NUMERICS "Build VXL's numerics libraries" YES )
OPTION( BUILD_CORE_SERIALISATION "Build VXL's serialisation libraries" YES )
OPTION( BUILD_CORE_UTILITIES "Build VXL's utility libraries" YES )
OPTION( BUILD_CORE_GEOMETRY "Build VXL's geometry libraries" YES )
OPTION( BUILD_CORE_IMAGING "Build VXL's imaging libraries" YES )
OPTION( BUILD_NONDEPRECATED_ONLY "Build only nondeprecated libraries (Experimental)" NO )
IF(BUILD_CORE_NUMERICS)
IF( BUILD_FOR_VXL_DASHBOARD )
OPTION( BUILD_CORE_PROBABILITY "Build VXL's probability libraries (Experimental)" YES )
ELSE( BUILD_FOR_VXL_DASHBOARD )
OPTION( BUILD_CORE_PROBABILITY "Build VXL's probability libraries (Experimental)" NO )
ENDIF( BUILD_FOR_VXL_DASHBOARD )
ENDIF(BUILD_CORE_NUMERICS)
SET (BUILD_CORE_ALL OFF CACHE INTERNAL "All Core libraries are being built")
IF (BUILD_CORE_GEOMETRY AND BUILD_CORE_NUMERICS)
IF (BUILD_CORE_UTILITIES AND BUILD_CORE_SERIALISATION)
IF (BUILD_CORE_IMAGING)
SET (BUILD_CORE_ALL ON CACHE INTERNAL "All Core libraries are being built")
ENDIF (BUILD_CORE_IMAGING)
ENDIF (BUILD_CORE_UTILITIES AND BUILD_CORE_SERIALISATION)
ENDIF (BUILD_CORE_GEOMETRY AND BUILD_CORE_NUMERICS)
# Optionally use old error reporting methods, rather than exceptions.
# The main use is in vil which often uses/used null images to imply an error.
OPTION (VXL_LEGACY_ERROR_REPORTING "Use old error reporting methods rather than exceptions?" YES)
IF (VXL_LEGACY_ERROR_REPORTING)
ADD_DEFINITIONS( -DVXL_LEGACY_ERROR_REPORTING )
ENDIF (VXL_LEGACY_ERROR_REPORTING)
# Options to build no longer maintained libraries.
# It is still useful to have the dashboard check that they are correct,
# but no-one is likely to work on improving test coverage or fixing memory leaks.
OPTION( BUILD_UNMAINTAINED_LIBRARIES "Build libraries that are no longer actively maintained?" ${YES_FOR_DASHBOARD} )
# Option to build Windows Unicode support, the string
# type of which is wchar_t, each character is a 16-bit unsigned integer.
IF(WIN32)
IF(VXL_HAS_WIN_WCHAR_T)
OPTION( VXL_USE_WIN_WCHAR_T "Build overloading functions that accept Windows wide char strings?" YES )
IF(VXL_USE_WIN_WCHAR_T) # Force it to be 0/1
SET(VXL_USE_WIN_WCHAR_T 1)
ELSE(VXL_USE_WIN_WCHAR_T)
SET(VXL_USE_WIN_WCHAR_T 0)
ENDIF(VXL_USE_WIN_WCHAR_T)
ELSE(VXL_HAS_WIN_WCHAR_T)
SET(VXL_USE_WIN_WCHAR_T 0)
ENDIF(VXL_HAS_WIN_WCHAR_T)
ELSE(WIN32)
# avoid empty macro definition
SET(VXL_USE_WIN_WCHAR_T 0)
ENDIF(WIN32)
# In order to be able to link vxl libraries into shared libraries on 64 bit linux, the -fPIC
# compiler flag must be added. Only do this if we are on a x86_64 *nix platform, we're building
# static libraries, and the user has not explicitly requested position dependent code.
IF(UNIX)
IF(NOT BUILD_SHARED_LIBS AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
OPTION(BUILD_POSITION_DEPENDENT_CODE "Generate position dependent code (i.e. code cannot be used in shared library)" OFF)
MARK_AS_ADVANCED(BUILD_POSITION_DEPENDENT_CODE)
IF (NOT BUILD_POSITION_DEPENDENT_CODE)
message(STATUS "Adding -fPIC compiler flag to generate position independent code.")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-fPIC")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-fPIC")
ENDIF(NOT BUILD_POSITION_DEPENDENT_CODE)
ENDIF(NOT BUILD_SHARED_LIBS AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
ENDIF(UNIX)
# Build the core vxl + support libraries
SUBDIRS(vcl v3p core)
# Optionally build the contributed libraries
IF( EXISTS ${vxl_SOURCE_DIR}/contrib/CMakeLists.txt )
OPTION( BUILD_CONTRIB "Build the contributed libraries?" YES )
ENDIF( EXISTS ${vxl_SOURCE_DIR}/contrib/CMakeLists.txt )
IF( BUILD_CONTRIB AND BUILD_CORE_ALL)
SUBDIRS( contrib )
ENDIF( BUILD_CONTRIB AND BUILD_CORE_ALL)
# Use the old configure script if the cache tells us to do so.
IF(VXL_NO_CMAKE_CONFIGURE)
IF(RUN_CONFIGURE)
EXEC_PROGRAM( ${vxl_SOURCE_DIR}/configure
${vxl_BINARY_DIR} )
ENDIF(RUN_CONFIGURE)
ENDIF(VXL_NO_CMAKE_CONFIGURE)
# Some types of path names can cause havoc with regular expressions,
# so avoid those.
IF( ${vxl_BINARY_DIR} MATCHES \\+ )
MESSAGE(SEND_ERROR "You cannot have a + in your binary path")
ENDIF( ${vxl_BINARY_DIR} MATCHES \\+ )
IF( ${vxl_SOURCE_DIR} MATCHES \\+ )
MESSAGE(SEND_ERROR "You cannot have a + in your source path")
ENDIF( ${vxl_SOURCE_DIR} MATCHES \\+ )
# include CMakeListsLocal.txt from source directory if it exists
# also include it from the binary dir if different from source dir
IF( ${vxl_BINARY_DIR} MATCHES ${vxl_SOURCE_DIR} )
INCLUDE( ${vxl_SOURCE_DIR}/CMakeListsLocal.txt OPTIONAL )
ELSE( ${vxl_BINARY_DIR} MATCHES ${vxl_SOURCE_DIR} )
INCLUDE( ${vxl_SOURCE_DIR}/CMakeListsLocal.txt OPTIONAL )
INCLUDE( ${vxl_BINARY_DIR}/CMakeListsLocal.txt OPTIONAL )
ENDIF( ${vxl_BINARY_DIR} MATCHES ${vxl_SOURCE_DIR} )
# Standard include directories.
SET(VXLCORE_INCLUDE_DIR ${vxl_BINARY_DIR}/core ${vxl_SOURCE_DIR}/core)
SET(VXLCORE_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/vxl/core)
SET(VCL_INCLUDE_DIR ${vxl_BINARY_DIR}/vcl ${vxl_SOURCE_DIR}/vcl)
SET(VCL_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/vxl/vcl)
# Autoconf does not work on windows. Use hardcoded results if not using
# cmake to configure.
IF(VXL_NO_CMAKE_CONFIGURE)
IF(WIN32)
IF(NOT CYGWIN)
SET(VCL_INCLUDE_DIR ${vxl_SOURCE_DIR}/vcl/config.win32 ${VCL_INCLUDE_DIR})
SET(VCL_INSTALL_INCLUDE_DIR
${CMAKE_INSTALL_PREFIX}/include/vcl/config.win32
${VCL_INSTALL_INCLUDE_DIR}
)
ENDIF(NOT CYGWIN)
ENDIF(WIN32)
ENDIF(VXL_NO_CMAKE_CONFIGURE)
INCLUDE_DIRECTORIES(${VCL_INCLUDE_DIR} ${VXLCORE_INCLUDE_DIR})
# This SUBDIRS command must be the last SUBDIRS command in this file
SUBDIRS( config/cmake/export )