I have followed this guide http://doc.qt.io/qt-5/gettingstartedqt.html and everything works fine.
But now I want to convert this project from qmake to cmake; this is the CMakeLists.txt
project(Notepad)
# Application Version, managed by release script
set(APPLICATIONS_VERSION_MAJOR "0")
set(APPLICATIONS_VERSION_MINOR "0")
set(APPLICATIONS_VERSION_MICRO "1")
set(APPLICATIONS_VERSION "${APPLICATIONS_VERSION_MAJOR}.${APPLICATIONS_VERSION_MINOR}.${APPLICATIONS_VERSION_MICRO}")
# Minimum required software
set(CMAKE_MIN_REQUIRED_VERSION "3.7.2")
set(QT_MIN_REQUIRED_VERSION "5.7.1")
set(KF5_MIN_REQUIRED_VERSION "5.31.0")
set(ECM_MIN_REQUIRED_VERSION "5.31.0")
cmake_minimum_required(VERSION "${CMAKE_MIN_REQUIRED_VERSION}" FATAL_ERROR)
# Configure ECM
find_package(ECM "${ECM_MIN_REQUIRED_VERSION}" REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include(FeatureSummary)
include(ECMSetupVersion)
# Generate header with version number
ecm_setup_version("${APPLICATIONS_VERSION}" VARIABLE_PREFIX NOTEPAD
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/notepad_version.h"
)
# Find Qt modules
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
Gui
Widgets
)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_CXX_STANDARD 11) # C++11...
set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11
set(notepad_SRCS main.cpp notepad.h notepad.cpp)
add_executable(notepad ${notepad_SRCS})
target_link_libraries(notepad
Qt5::Widgets
Qt5::Core
Qt5::Gui
)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
And I get this output:
/documenti/deglans/Programmazione/QtCreator/Notepad/build> make -j4
Scanning dependencies of target notepad_automoc
[ 25%] Automatic uic for target notepad
Generating ui header ui_notepad.h
[ 25%] Built target notepad_automoc
Scanning dependencies of target notepad
[ 50%] Building CXX object CMakeFiles/notepad.dir/main.cpp.o
[ 75%] Building CXX object CMakeFiles/notepad.dir/notepad.cpp.o
[100%] Linking CXX executable notepad
CMakeFiles/notepad.dir/notepad.cpp.o: In function `Notepad::Notepad(QWidget*)':
/documenti/deglans/Programmazione/QtCreator/Notepad/notepad.cpp:28: undefined reference to `vtable for Notepad'
/documenti/deglans/Programmazione/QtCreator/Notepad/notepad.cpp:28: undefined reference to `vtable for Notepad'
CMakeFiles/notepad.dir/notepad.cpp.o: In function `Notepad::~Notepad()':
/documenti/deglans/Programmazione/QtCreator/Notepad/notepad.cpp:33: undefined reference to `vtable for Notepad'
/documenti/deglans/Programmazione/QtCreator/Notepad/notepad.cpp:33: undefined reference to `vtable for Notepad'
CMakeFiles/notepad.dir/notepad.cpp.o: In function `Notepad::tr(char const*, char const*, int)':
/documenti/deglans/Programmazione/QtCreator/Notepad/notepad.h:28: undefined reference to `Notepad::staticMetaObject'
collect2: error: ld returned 1 exit status
CMakeFiles/notepad.dir/build.make:123: recipe for target 'notepad' failed
make[2]: *** [notepad] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/notepad.dir/all' failed
make[1]: *** [CMakeFiles/notepad.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
*** Errore: Codice di uscita 2 ***
This is the part of code that give error when using cmake:
Notepad::Notepad(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Notepad)
{
ui->setupUi(this);
}
Notepad::~Notepad()
{
delete ui;
}
Note that with qmake and QtCreator I have non problem, the problem born when I try to use KDevelop and cmake.
I have resolved the problem by adding this line set(CMAKE_AUTOMOC ON) as suggested by Lorenz.
So CMakeLists.txt become:
project(Notepad)
# Application Version, managed by release script
set(APPLICATIONS_VERSION_MAJOR "0")
set(APPLICATIONS_VERSION_MINOR "0")
set(APPLICATIONS_VERSION_MICRO "1")
set(APPLICATIONS_VERSION "${APPLICATIONS_VERSION_MAJOR}.${APPLICATIONS_VERSION_MINOR}.${APPLICATIONS_VERSION_MICRO}")
# Minimum required software
set(CMAKE_MIN_REQUIRED_VERSION "3.7.2")
set(QT_MIN_REQUIRED_VERSION "5.7.1")
set(KF5_MIN_REQUIRED_VERSION "5.31.0")
set(ECM_MIN_REQUIRED_VERSION "5.31.0")
cmake_minimum_required(VERSION "${CMAKE_MIN_REQUIRED_VERSION}" FATAL_ERROR)
# Configure ECM
find_package(ECM "${ECM_MIN_REQUIRED_VERSION}" REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include(FeatureSummary)
include(ECMSetupVersion)
# Generate header with version number
ecm_setup_version("${APPLICATIONS_VERSION}" VARIABLE_PREFIX NOTEPAD
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/notepad_version.h"
)
# Find Qt modules
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
Gui
Widgets
)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON) # <<<<<<<-----------------------------
set(CMAKE_CXX_STANDARD 11) # C++11...
set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11
set(notepad_SRCS main.cpp notepad.h notepad.cpp)
add_executable(notepad ${notepad_SRCS})
target_link_libraries(notepad
Qt5::Widgets
Qt5::Core
Qt5::Gui
)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
Related
I'm on macOS 12.4 I have run xcode-select --install to install the build tools. I'm using VSCode and my c++ configurations I've added the mac frameworks as.
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks and /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/ The reason I added this second one is it contains a string.h file which contains a declaration for memset_s
The error generated is this:
/Users/Greeley/Workspace/Cppspace/Culinoire/build/subprojects/Source/wxWidgets_external/src/unix/utilsunx.cpp:229:5: error: use of undeclared identifier 'memset_s'
memset_s(v, n, 0, n);
^
1 error generated.
make[5]: *** [libs/base/CMakeFiles/wxbase.dir/__/__/__/__/src/unix/utilsunx.cpp.o] Error 1
make[4]: *** [libs/base/CMakeFiles/wxbase.dir/all] Error 2
make[3]: *** [all] Error 2
My code is here: https://github.com/Greeley/Culinoire but it's just CMakeLists.txt files right now, and the wxWidgets Hello World as main.cpp also my .vscode directory.
I followed this: this video https://www.youtube.com/watch?v=zdHqoyG73Jk
and this one https://www.youtube.com/watch?v=MfuBS9n5_aY
And then found this on github with the same issue.
https://github.com/wxWidgets/wxWidgets/issues/19334
and put the define at the top of main.cpp and put it in the defines array within c_cpp_properties.json however I still get the same error as above.
I really don't understand what's going wrong. I'd greatly appreciate some help.
there's 4 CMakeLists.txt in the project, these are their contents:
/CMakeLists.txt
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
set(CMAKE_C_COMPILER "/Library/Developer/CommandLineTools/usr/bin/c")
set(CMAKE_CXX_COMPILER "/Library/Developer/CommandLineTools/usr/bin/c++")
project(Culinoire LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# ExternalProject base
set_property(DIRECTORY PROPERTY EP_BASE ${CMAKE_BINARY_DIR}/subprojects)
set(STAGED_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/stage)
add_subdirectory(external)
include(ExternalProject)
ExternalProject_Add(${PROJECT_NAME}_core
DEPENDS
wxWidgets_external
SOURCE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/src
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}
-DwxWidgets_ROOT_DIR=${wxWidgets_ROOT_DIR}
-DENV_WX_CONFIG=${ENV_WX_CONFIG}
CMAKE_CACHE_ARGS
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
BUILD_ALWAYS
1
INSTALL_COMMAND
""
)
Edit below: Changed static to 1 and universal to 0
/src/CMakeLists.txt
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
set(CMAKE_C_COMPILER "/Library/Developer/CommandLineTools/usr/bin/c")
set(CMAKE_CXX_COMPILER "/Library/Developer/CommandLineTools/usr/bin/c++")
project(wx_cmake_template_core LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(__STDC_WANT_LIB_EXT1__)
# hack for buggy CMake's FindwxWidgets script
if (DEFINED ENV_WX_CONFIG)
set (ENV{WX_CONFIG} ${ENV_WX_CONFIG})
endif()
set(wxWidgets_USE_DEBUG 1)
set(wxWidgets_USE_UNICODE 1)
set(wxWidgets_USE_UNIVERSAL 0)
set(wxWidgets_USE_STATIC 1)
set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr)
set(wxWidgets_ROOT_DIR "/Users/Greeley/Library/wxWidgets")
set(wxWidgets_LIBRARIES "/Users/Greeley/Library/wxWidgets/lib")
find_package(wxWidgets COMPONENTS core base REQUIRED HINT ${wxWidgets_ROOT_DIR})
set(SRCS main.cpp)
if (APPLE)
# create bundle on apple compiles
add_executable(main MACOSX_BUNDLE ${SRCS} )
# Set a custom plist file for the app bundle - needed for Mac OS Retina display
set_target_properties(main PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
else()
# the WIN32 is needed for Windows in order for it to look for WinMain
# instead of the main function. This is ignored on other systems,
# so it works on all platforms
add_executable(main WIN32 ${SRCS})
endif()
target_link_libraries(main PRIVATE ${wxWidgets_LIBRARIES})
/external/CMAkeLists.txt
add_subdirectory(wxwidgets)
/external/wxwidgets/CMakeLists.txt
# check if wxWidgets is already installed in the system - using CMake's built in script FindwxWidgets
find_package(wxWidgets QUIET)
if (wxWidgets_FOUND)
message(STATUS "Found preinstalled wxWidgets libraries at ${wxWidgets_LIBRARIES}")
add_library(wxWidgets_external INTERFACE)
else()
message(STATUS "Preinstalled wxWidgets not found.")
message(STATUS "Will download and install wxWidgets in ${STAGED_INSTALL_PREFIX}")
include(ExternalProject)
ExternalProject_Add(wxWidgets_external
GIT_REPOSITORY
https://github.com/wxWidgets/wxWidgets.git
GIT_TAG
3.2
UPDATE_COMMAND
""
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}
-DCMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}
-DwxBUILD_SHARED=OFF
CMAKE_CACHE_ARGS
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
TEST_AFTER_INSTALL
0
DOWNLOAD_NO_PROGRESS
1
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
)
set(wxWidgets_ROOT_DIR ${STAGED_INSTALL_PREFIX})
file(TO_NATIVE_PATH "${wxWidgets_ROOT_DIR}" wxWidgets_ROOT_DIR)
set(wxWidgets_ROOT_DIR ${wxWidgets_ROOT_DIR} CACHE INTERNAL "wxWidgets installation dir")
set (ENV_WX_CONFIG ${STAGED_INSTALL_PREFIX}/bin/wx-config)
file (TO_NATIVE_PATH "${ENV_WX_CONFIG}" ENV_WX_CONFIG)
set(ENV_WX_CONFIG ${ENV_WX_CONFIG} CACHE INTERNAL "wx-config dir")
endif()
EDIT BELOW
I changed the CMakeLists.txt file to
# check if wxWidgets is already installed in the system - using CMake's built in script FindwxWidgets
find_package(wxWidgets QUIET)
if (wxWidgets_FOUND)
message(STATUS "Found preinstalled wxWidgets libraries at ${wxWidgets_LIBRARIES}")
add_library(wxWidgets INTERFACE)
else()
message(STATUS "Preinstalled wxWidgets not found.")
message(STATUS "Will download and install wxWidgets in ${STAGED_INSTALL_PREFIX}")
include(ExternalProject)
ExternalProject_Add(wxWidgets
GIT_REPOSITORY
https://github.com/wxWidgets/wxWidgets.git
GIT_TAG
master
UPDATE_COMMAND
""
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DwxBUILD_SHARED=OFF
CMAKE_CACHE_ARGS
TEST_AFTER_INSTALL
0
DOWNLOAD_NO_PROGRESS
1
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
)
set(wxWidgets_ROOT_DIR ${STAGED_INSTALL_PREFIX})
file(TO_NATIVE_PATH "${wxWidgets_ROOT_DIR}" wxWidgets_ROOT_DIR)
set(wxWidgets_ROOT_DIR ${wxWidgets_ROOT_DIR} CACHE INTERNAL "wxWidgets installation dir")
set (ENV_WX_CONFIG ${STAGED_INSTALL_PREFIX}/bin/wx-config)
file (TO_NATIVE_PATH "${ENV_WX_CONFIG}" ENV_WX_CONFIG)
set(ENV_WX_CONFIG ${ENV_WX_CONFIG} CACHE INTERNAL "wx-config dir")
endif()
The build now completes and wxWidgets is 'found' but then goes to fail because wx/wx.h isn't found
-- Found wxWidgets: -L/Users/Greeley/Workspace/Cppspace/Culinoire/build/stage/lib;-pthread;/Users/Greeley/Workspace/Cppspace/Culinoire/build/stage/lib/libwx_osx_cocoau_core-3.2.a;/Users/Greeley/Workspace/Cppspace/Culinoire/build/stage/lib/libwx_baseu-3.2.a;-lwx_baseu-3.2;-lwxjpeg-3.2;-lwxpng-3.2;-lwxtiff-3.2;-framework AudioToolbox;-framework WebKit;/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/lib/libz.tbd;-lwxregexu-3.2;/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/lib/libiconv.tbd;-framework CoreFoundation;-framework Security;-framework Carbon;-framework Cocoa;-framework IOKit;-framework QuartzCore (found version "3.2.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/Greeley/Workspace/Cppspace/Culinoire/build/subprojects/Build/Culinoire_core
[ 87%] Performing build step for 'Culinoire_core'
[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
/Users/Greeley/Workspace/Cppspace/Culinoire/src/main.cpp:3:10: fatal error: 'wx/wxprec.h' file not found
#include <wx/wxprec.h>
^~~~~~~~~~~~~
1 error generated.
make[5]: *** [CMakeFiles/main.dir/main.cpp.o] Error 1
make[4]: *** [CMakeFiles/main.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [subprojects/Stamp/Culinoire_core/Culinoire_core-build] Error 2
make[1]: *** [CMakeFiles/Culinoire_core.dir/all] Error 2
make: *** [all] Error 2
in /src/CMakeLists.txt I added
include(${wxWidgets_USE_FILE})
and changed the project name to reflect my actual project name.
so the entire file looks like this
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
set(CMAKE_C_COMPILER "/Library/Developer/CommandLineTools/usr/bin/c")
set(CMAKE_CXX_COMPILER "/Library/Developer/CommandLineTools/usr/bin/c++")
project(Culinoire LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(__STDC_WANT_LIB_EXT1__)
# hack for buggy CMake's FindwxWidgets script
if (DEFINED ENV_WX_CONFIG)
set (ENV{WX_CONFIG} ${ENV_WX_CONFIG})
endif()
set(wxWidgets_USE_DEBUG 1)
set(wxWidgets_USE_UNICODE 1)
set(wxWidgets_USE_UNIVERSAL 0)
set(wxWidgets_USE_STATIC 1)
#set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr)
find_package(wxWidgets COMPONENTS core base REQUIRED)
set(SRCS main.cpp)
include(${wxWidgets_USE_FILE})
if (APPLE)
# create bundle on apple compiles
add_executable(main MACOSX_BUNDLE ${SRCS} )
# Set a custom plist file for the app bundle - needed for Mac OS Retina display
set_target_properties(main PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
else()
# the WIN32 is needed for Windows in order for it to look for WinMain
# instead of the main function. This is ignored on other systems,
# so it works on all platforms
add_executable(main WIN32 ${SRCS})
endif()
target_link_libraries(main PRIVATE ${wxWidgets_LIBRARIES})
and my output now is
[main] Building folder: Culinoire
[build] Starting build
[proc] Executing command: /usr/local/bin/cmake --build /Users/Greeley/Workspace/Cppspace/Culinoire/build --config Debug --target all -j 10 --
[build] [ 50%] Built target wxWidgets
[build] [ 56%] Performing build step for 'Culinoire_core'
[main] Changes were detected in CMakeLists.txt but we could not reconfigure the project because another operation is already in progress.
[build] -- Configuring done
[build] -- Generating done
[build] -- Build files have been written to: /Users/Greeley/Workspace/Cppspace/Culinoire/build/subprojects/Build/Culinoire_core
[build] [ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
[build] [100%] Linking CXX executable main.app/Contents/MacOS/main
[build] [100%] Built target main
[build] [ 62%] No install step for 'Culinoire_core'
[build] [ 68%] Completed 'Culinoire_core'
[build] [100%] Built target Culinoire_core
[build] Build finished with exit code 0
[cpptools] The build configurations generated do not contain the active build configuration. Using "" for CMAKE_BUILD_TYPE instead of "Debug" to ensure that IntelliSense configurations can be found
I have been given a custom C++ library which I need for some simulations that I'm writing, and have been told I should build this using CMake (I should note I have never used CMake before). I am trying to write a CMakeLists.txt file so that I can call functions from this library. No matter what method I seem to try it does not want to link, however it is fine with including all of the relevant header files now.
For context on the step up, I have Ubuntu on WSL but the library I need is located on an external hard drive, I can change the structure of this if this is where the issues lie.
On WSL I have: project folder (where CMakeLists.txt is) -> subdir called Build (where I'm trying to build it).
The library structure is: D://some_path/Positioner->Poslib (the header files I need are here)
Data
Configure
ect.
The library also has a build folder under Positioner, with the same subdirectory names that each include a libname.a file.
I am trying to link to most of the library subdirectories to avoid dependency issues. The functions I'm trying to call all use the namespace Pos if that's relevant.
Below is my CMakeLists.txt setup (I have a lot of stuff I've tested commented out sorry):
project(wrapDelta)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 17)
#set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_AUTOMOC ON)
# Various compiler warnings from external include files are disabled with
# GCC pragmas but these are not supported before gcc version 6.
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 6)
add_compile_options(-Wall -pedantic-errors -Wextra -Werror)
else()
add_compile_options(-Wall -pedantic-errors -Wextra -Werror
-Wno-unused-variable -Wno-unused-parameter
-Wno-maybe-uninitialized)
endif()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Default path for finding the SOFA library
set(SOFA_DIR /home/name/sofa/20210512/c/src)
#Setting directories for different positioner software libraries
set(POSLIB_DIR ${/mnt/d/pos/positioner/poslib/})
set(DATA_DIR ${/mnt/d/pos/positioner/data})
set(PLATE_GEN_DIR ${/mnt/d/pos/positioner/plate_gen})
set(CONFIGURE_DIR ${/mnt/d/pos/positioner/configure})
set(LIFU_DIR ${/mnt/d/pos/positioner/lifu_configure})
set(BOOST_INCLUDEDIR $ENV{/home/name/boost_1_77_0/boost})
set(BOOST_LIBRARYDIR $ENV{/usr/lib/x86_64-linux-gnu})
set(boost_filesystem_DIR /mnt/c/Program Files/boost/boost_1_77_0/stage/lib/cmake/boost_filesystem-1.77.0)
find_package(Boost 1.6 REQUIRED CONFIG
COMPONENTS program_options system filesystem log unit_test_framework
)
find_library(SOFA t_sofa_c REQUIRED PATHS ${SOFA_DIR}) #libsofa_c.a REQUIRED PATHS /home/name/starlink/starlink/thirdparty/sofa/sofa/src)#/lib at the end
find_package(Qt5 5.9.5 REQUIRED COMPONENTS Core Widgets Xml PrintSupport Gui)
#find_library(LIB_POSLIB NAMES poslib libposlib.a REQUIRED PATHS ${POSLIB_DIR} NO_DEFAULT_PATH)
include_directories(/home/name/sofa/20210512/c/src) #/home/name/starlink/starlink/thirdparty/sofa/sofa/src)
include_directories(/mnt/d/pos/positioner/poslib)
include_directories(/mnt/d/pos/positioner/data)
include_directories(/mnt/d/pos/positioner/plate_gen)
include_directories(/mnt/d/pos/positioner/configure)
include_directories(/mnt/d/pos/positioner/lifu_configure)
include_directories(/mnt/d/pos/positioner/build/poslib)
include_directories(/mnt/d/pos/positioner/build/data)
include_directories(/mnt/d/pos/positioner/build/plate_gen)
include_directories(/mnt/d/pos/positioner/build/configure)
include_directories(/mnt/d/pos/positioner/build/lifu_configure)
include_directories(/mnt/d/pos/positioner/build/poslib)
include_directories(${Qt5Core_INCLUDE_DIRS})
include_directories(${Qt5Widgets_INCLUDE_DIRS})
include_directories(${Qt5Xml_INCLUDE_DIRS})
include_directories(${Qt5PrintSupport_INCLUDE_DIRS})
include_directories(${Qt5Gui_INCLUDE_DIRS})
link_directories(/home/name/sofa/20210512/c/src/) #/home/name/starlink/starlink/thirdparty/sofa/sofa/src)
link_directories("/mnt/d/pos/positioner/poslib/")
link_directories("/mnt/d/pos/positioner/data/")
link_directories("/mnt/d/pos/positioner/plate_gen/")
link_directories("/mnt/d/pos/positioner/configure/")
link_directories("/mnt/d/pos/positioner/lifu_configure/")
link_directories("/mnt/d/pos/positioner/build/poslib/")
link_directories("/mnt/d/pos/positioner/build/data/")
link_directories("/mnt/d/pos/positioner/build/plate_gen/")
link_directories("/mnt/d/pos/positioner/build/configure/")
link_directories("/mnt/d/pos/positioner/build/lifu_configure/")
file(GLOB poslib_Sources RELATIVE "/mnt/d/pos/positioner/poslib/" "*.cpp")
file(GLOB poslib_h_Sources RELATIVE "/mnt/d/pos/positioner/poslib/" "*.h")
add_executable(delta_wrap_test Delta_wrap_test.cpp ${poslib_Sources} ${poslib_h_Sources})
qt5_use_modules(delta_wrap_test Core Xml Gui Widgets PrintSupport)
add_library(python_delta SHARED Delta_wrap_test.cpp)
add_library(data STATIC IMPORTED GLOBAL)
set_target_properties(data PROPERTIES IMPORTED_LOCATION $ENV{/mnt/d/pos/positioner/build/data}/libconfig_files_resource.a)
add_library(plate_gen STATIC IMPORTED GLOBAL)
set_target_properties(plate_gen PROPERTIES IMPORTED_LOCATION $ENV{/mnt/d/pos/positioner/plate_gen}/libplate_files_resource.a)
add_library(configure SHARED IMPORTED GLOBAL)
set_target_properties(configure PROPERTIES IMPORTED_LOCATION $ENV{/mnt/d/pos/positioner/configure}/configure.cpp) #configure
add_library(lifu SHARED IMPORTED GLOBAL)
set_target_properties(lifu PROPERTIES IMPORTED_LOCATION $ENV{/mnt/d/pos/positioner/lifu_configure}/lifu_configure.cpp) #lifu_configure
add_library(sofa STATIC IMPORTED GLOBAL)
set_target_properties(sofa PROPERTIES IMPORTED_LOCATION $ENV{/home/name/sofa/20210512/c/src}/libsofa.a)
add_library(poslib STATIC IMPORTED GLOBAL)
set_target_properties(poslib PROPERTIES IMPORTED_LOCATION "/mnt/d/pos/positioner/build/poslib/")#$ENV{/mnt/d/pos/positioner/build/poslib}/libposlib.a)
#target_link_libraries(delta_wrap_test ${/mnt/d/pos/positioner/data})
#target_link_libraries(delta_wrap_test ${/mnt/d/pos/positioner/plate_gen})
#target_link_libraries(delta_wrap_test ${/mnt/d/pos/positioner/configure})
#target_link_libraries(delta_wrap_test ${/mnt/d/pos/positioner/lifu_configure})
#target_link_libraries(delta_wrap_test ${/mnt/d/pos/positioner/poslib})
#target_link_libraries(${delta_wrap_test} ${/home/name/sofa/20210512/c/src})
target_link_libraries(delta_wrap_test
${sofa}
${Boost_LIBRARIES}
Qt5::Core
Qt5::Widgets
Qt5::Xml
Qt5::PrintSupport
Qt5::Gui
Threads::Threads
)
#${LIB_POSLIB}
Currently this is the error message I am getting:
Scanning dependencies of target delta_wrap_test_autogen
[ 12%] Automatic MOC for target delta_wrap_test
[ 12%] Built target delta_wrap_test_autogen
Scanning dependencies of target delta_wrap_test
[ 25%] Building CXX object CMakeFiles/delta_wrap_test.dir/Delta_wrap_test.cpp.o
[ 37%] Building CXX object CMakeFiles/delta_wrap_test.dir/delta_wrap_test_autogen/mocs_compilation.cpp.o
[ 50%] Linking CXX executable delta_wrap_test
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
CMakeFiles/delta_wrap_test.dir/Delta_wrap_test.cpp.o: In function `Delta_wrap_test::define(QString)':
Delta_wrap_test.cpp:(.text+0xa7): undefined reference to `pos::loadXmlFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
CMakeFiles/delta_wrap_test.dir/Delta_wrap_test.cpp.o: In function `Delta_wrap_test::applyMove()':
Delta_wrap_test.cpp:(.text+0x1d4): undefined reference to `pos::PhysicalPlate::parkFibre(int, bool)'
Delta_wrap_test.cpp:(.text+0x1e1): undefined reference to `pos::Plate::moveFibre(int, bool)'
Delta_wrap_test.cpp:(.text+0x1fd): undefined reference to `pos::Delta::dumpFibre(unsigned int) const'
collect2: error: ld returned 1 exit status
CMakeFiles/delta_wrap_test.dir/build.make:134: recipe for target 'delta_wrap_test' failed
make[2]: *** [delta_wrap_test] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/delta_wrap_test.dir/all' failed
make[1]: *** [CMakeFiles/delta_wrap_test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Any help/advice would be really appreciated, as at this stage I am just running out of ideas.
So I have fixed this problem now using
target_link_libraries(delta_wrap_test "/mnt/d/pos/positioner/build/poslib/libposlib.a")
However, I have now realised the further errors that I get from this are from the libposlib.a library depending on the Sofa library I'm also linking too, so I believe that I need to make a new static library linking those before this will work. Any advice on linking static libraries together from different directories would be welcome.
#####Update####
Here is the final CMake final that was able to compile my code without errors:
cmake_minimum_required(VERSION 3.5)
cmake_policy(SET CMP0060 NEW)
project(wrapDelta)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 14)
#set(CMAKE_CXX_STANDARD 17)
#set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_AUTOMOC ON)
set(LINUX TRUE)
# Various compiler warnings from external include files are disabled with
# GCC pragmas but these are not supported before gcc version 6.
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 6)
add_compile_options( -L/usr/lib/x86_64-linux-gnu -lboost_system-Wall -pedantic-errors -Wextra -Werror)
else()
add_compile_options( -L/usr/lib/x86_64-linux-gnu -lboost_system -Wall -pedantic-errors -Wextra -Werror
-Wno-unused-variable -Wno-unused-parameter
-Wno-maybe-uninitialized -DBoost_USE_STATIC_LIBS=ON)
endif()
#set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#set(Boost_NO_BOOST_CMAKE TRUE)
#set(Boost_NO_SYSTEM_PATHS TRUE)
#set(Boost_USE_STATIC_LIBS TRUE)
set(Boost_USE_STATIC_LIBS OFF)
#set(Boost_USE_MULTITHREADED ON)
#set(Boost_USE_STATIC_RUNTIME OFF)
#set(Boost_NO_SYSTEM_PATHS TRUE)
SET(Boost_DEBUG ON)
#set( BOOST_ROOT "" CACHE PATH /usr/lib/x86_64-linux-gnu/ )
#set( Boost_NO_SYSTEM_PATHS on CACHE BOOL "Do not search system for Boost" )
# Default path for finding the SOFA library
set(SOFA_DIR /home/name/sofa/20210512/c/src/)
#Setting directories for different positioner software libraries
set(POSLIB_DIR /mnt/d/pos/positioner/build/poslib/) #/mnt/d/pos/positioner/poslib/)
set(DATA_DIR "mnt/d/pos/positioner/data")
set(PLATE_GEN_DIR "/mnt/d/pos/positioner/plate_gen")
set(CONFIGURE_DIR "/mnt/d/pos/positioner/configure")
set(LIFU_DIR "/mnt/d/pos/positioner/lifu_configure")
#set(Boost_ROOT /usr/include/boost/)
#set(Boost_DIR /usr/include/boost/)
#set(BOOST_INCLUDEDIR /usr/lib/x86_64-linux-gnu/)
#set(BOOST_LIBRARYDIR /usr/lib/x86_64-linux-gnu/)
#set(boost_filesystem_DIR /usr/lib/x86_64-linux-gnu/)
###testing library inclusion
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(LIBS ${/usr/lib/cmake/Boost-1.77.0/})
find_package(Boost 1.65 REQUIRED CONFIG
COMPONENTS filesystem program_options log unit_test_framework system PATHS ${BOOST_ROOT})
#EXACT
IF (Boost_FOUND)
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIR})
link_directories (${BOOST_LIBRARYDIR})
ENDIF()
find_library(LIB_POSLIB NAMES poslib REQUIRED PATHS ${POSLIB_DIR})
####keep the library name as Sofa not SOFA
find_library(Sofa libsofa_c.a REQUIRED PATHS ${SOFA_DIR})
find_package(Qt5 5.9.5 REQUIRED COMPONENTS Core Widgets Xml PrintSupport Gui)
include_directories("/home/name/sofa/20210512/c/src/")
include_directories("/mnt/d/pos/positioner/poslib/")
include_directories("/mnt/d/pos/positioner/data/")
include_directories("/mnt/d/pos/positioner/plate_gen/")
include_directories("/mnt/d/pos/positioner/configure/")
include_directories("/mnt/d/pos/positioner/lifu_configure/")
include_directories("/mnt/d/pos/positioner/build/poslib/")
include_directories("/mnt/d/pos/positioner/build/data/")
include_directories("/mnt/d/pos/positioner/build/plate_gen/")
include_directories("/mnt/d/pos/positioner/build/configure/")
include_directories("/mnt/d/pos/positioner/build/lifu_configure/")
include_directories("/mnt/d/pos/positioner/build/poslib/")
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${Qt5Widgets_INCLUDE_DIRS})
include_directories(${Qt5Core_INCLUDE_DIRS})
include_directories(${Qt5Xml_INCLUDE_DIRS})
include_directories(${Qt5PrintSupport_INCLUDE_DIRS})
include_directories(${Qt5Gui_INCLUDE_DIRS})
link_directories("/home/sarah/sofa/20210512/c/src/")
link_directories("/mnt/d/pos/positioner/poslib/")
link_directories("/mnt/d/pos/positioner/data/")
link_directories("/mnt/d/pos/positioner/plate_gen/")
link_directories("/mnt/d/pos/positioner/configure/")
link_directories("/mnt/d/pos/positioner/lifu_configure/")
link_directories("/mnt/d/pos/positioner/build/poslib/")
link_directories("/mnt/d/pos/positioner/build/data/")
link_directories("/mnt/d/pos/positioner/build/plate_gen/")
link_directories("/mnt/d/pos/positioner/build/configure/")
link_directories("/mnt/d/pos/positioner/build/lifu_configure/")
link_directories(${Boost_LIBRARY_DIRS})
add_executable(delta_wrap_test Delta_wrap_test.cpp ${poslib_Sources} ${poslib_h_Sources})
qt5_use_modules(delta_wrap_test Core Xml Gui Widgets PrintSupport)
add_library(python_delta SHARED Delta_wrap_test.cpp)
target_link_libraries(delta_wrap_test
${LIB_POSLIB}
${Sofa}
boost_filesystem
boost_system
${Boost_LIBRARIES}
Boost::system
Boost::thread
Qt5::Core
Qt5::Widgets
Qt5::Xml
Qt5::PrintSupport
Qt5::Gui
Threads::Threads
)
Cross-compiling c++ test application for aarch64 compiler and linking boost library using Cmake files. I keep getting this error that the format of the boost library is not correct. Here is my CMakeList and the error im getting.
CMakeLists.txt:
cmake_minimum_required(VERSION "3.10.2")
project(testapp2)
# Target operating system name.
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
# Name of C compiler.
set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
#set(CMAKE_CXX_FLAGS "-m32")
set(BOOST_ROOT "./local/boost_1_73_0") # either set it here or from the command line
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_INCLUDE_DIRS "./local/boost_1_73_0/boost")
find_package(Boost REQUIRED COMPONENTS system)
add_executable(testapp2 main.cpp)
install(TARGETS testapp2 DESTINATION bin)
install(FILES main.cpp DESTINATION src)
target_include_directories(testapp2 PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(testapp2 ${Boost_LIBRARIES})
Error:
usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
I've tried to add the -DCMAKE_CXX_FLAGS="m32" and it gave me this error:
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCXXCompiler.cmake:45 (message):
The C++ compiler
"/usr/bin/c++"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /root/testapp2/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_3dc9d/fast"
/usr/bin/make -f CMakeFiles/cmTC_3dc9d.dir/build.make CMakeFiles/cmTC_3dc9d.dir/build
make[1]: Entering directory '/root/testapp2/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_3dc9d.dir/testCXXCompiler.cxx.o
/usr/bin/c++ m32 -o CMakeFiles/cmTC_3dc9d.dir/testCXXCompiler.cxx.o -c /root/testapp2/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
c++: error: m32: No such file or directory
I'm trying to build a Qt5 project with Cmake in order to add some new librairies. The cmake goes well but I have a linking issue when building :
Linking CXX executable bin/qGo
CMakeFiles/qGo.dir/src/main.cpp.o: dans la fonction « main »:
main.cpp:(.text+0x102b): undefined reference to « qInitResources_application() »
collect2: error: ld returned 1 exit status
make[2]: *** [bin/qGo] Erreur 1
make[1]: *** [CMakeFiles/qGo.dir/all] Erreur 2
make: *** [all] Erreur 2
Here is my CMakeLists.txt :
cmake_minimum_required(VERSION 2.8.11)
project (qGo)
SET(CMAKE_MODULE_PATH /usr/local/lib/cmake/)
# Répertoire d'installation de Qt5 (dépend de l'installation)
SET(CMAKE_PREFIX_PATH "~/Qt/5.4/gcc/")
find_package (OpenCV REQUIRED)
find_package (aruco REQUIRED)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Use moc files in the bin folder
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
# Find the Qt5 components
find_package(Qt5Core)
find_package(Qt5Widgets)
find_package(Qt5Network)
find_package(Qt5Multimedia)
set(EXECUTABLE_OUTPUT_PATH bin)
SET(CMAKE_CXX_FLAGS "-std=c++11")
include_directories(src)
include_directories(src/audio)
include_directories(src/board)
include_directories(src/game_interfaces)
include_directories(src/game_tree)
include_directories(src/gtp)
include_directories(src/network)
include_directories(src/resources)
include_directories(src/sgf)
include_directories(src/translations)
file(
GLOB_RECURSE
source_files
src/*
)
file(
GLOB_RECURSE
ui_files
src/*.ui
)
file(
GLOB_RECURSE
header_files
src/*.h
src/*.hpp
)
QT5_WRAP_UI(header_ui ${ui_files})
# Tell CMake to create the helloworld executable
add_executable(qGo ${source_files} ${header_ui})
# Use the Widgets module from Qt 5.
target_link_libraries(qGo Qt5::Core Qt5::Widgets Qt5::Network Qt5::Multimedia ${OpenCV_LIBS} ${aruco_LIBS})
I have also tried to add libraries with ${Qt5Widgets_INCLUDES} or ${Qt5Widgets_DEFINITIONS} but it did the same.
I've also tried to compile with QtCreator and it works so the problem is with cmake.
I think you forget to append moc and resources to your executable use qt5_wrap_cpp() for mocs use qt5_add_resources() for resources.
Then you must append vars to add_executable check out this link.
I was able to successfully configure and generate the build folder (KinectSLAM6D/build.). However, when I try to build it using make, I got an error saying gsl is not found. I am pretty sure this is just a configuration issue as I have gsl installed (they're in usr/local), but I am unable to configure it. I have tried adding the following lines to CMakeList:
include_directories(${GSL_INCLUDE_DIRS} ${GSLCBLAS_INCLUDE_DIRS})
set(LIBS ${LIBS} ${GSL_LIBRARIES} ${GSLCBLAS_LIBRARIES})
I have copied the pertinent output below. I have found a couple of answers to compiling with gsl (adding -lgsl). However, I have no clue where to put that in CMakeLists or the generated MakeList and MakeList2 files.
Here's the generated output.
....
[ 44%] Building CXX object CMakeFiles/Kinect6DSLAM.dir/src/GraphOptimizer_G2O.cpp.o
[ 45%] Building CXX object CMakeFiles/Kinect6DSLAM.dir/src/CKinect2DRawlog.cpp.o
Linking CXX executable Kinect6DSLAM
/usr/bin/ld: warning: libopencv_core.so.2.3, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libmrpt-base.so, may conflict with libopencv_core.so.2.4
/usr/bin/ld: warning: libopencv_imgproc.so.2.3, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libmrpt-base.so, may conflict with libopencv_imgproc.so.2.4
/usr/bin/ld: warning: libopencv_highgui.so.2.3, needed by /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libmrpt-base.so, may conflict with libopencv_highgui.so.2.4
../gicp/libgicp.a(gicp.o): In function `dgc::gicp::GICPPointSet::ComputeMatrices()':
gicp.cpp:(.text+0x462): undefined reference to `gsl_vector_alloc'
gicp.cpp:(.text+0x470): undefined reference to `gsl_vector_alloc'
... a bunch more undefined references to gsl
collect2: ld returned 1 exit status
make[2]: *** [Kinect6DSLAM] Error 1
make[1]: *** [CMakeFiles/Kinect6DSLAM.dir/all] Error 2
make: *** [all] Error 2
This if the full CMakeList.txt. I am trying to run Miguel Algaba's SLAM project.
PROJECT(KinectSLAM6D)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW) # Required by CMake 2.7+
endif(COMMAND cmake_policy)
# Set the output directory for the build executables
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/build)
#Add here your project dependencies
FIND_PACKAGE(MRPT REQUIRED hwdrivers maps graphslam) #Add here your project dependencies
FIND_PACKAGE(PCL REQUIRED)
FIND_PACKAGE(OpenCV REQUIRED )
INCLUDE_DIRECTORIES(${PCL_INCLUDE_DIRS})
LINK_DIRECTORIES(${PCL_LIBRARY_DIRS})
ADD_DEFINITIONS(${PCL_DEFINITIONS})
# Required by StanfordGICP
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
FIND_PACKAGE(GSL REQUIRED)
include_directories(${GSL_INCLUDE_DIRS} ${GSLCBLAS_INCLUDE_DIRS})
set(LIBS ${LIBS} ${GSL_LIBRARIES} ${GSLCBLAS_LIBRARIES})
FIND_PACKAGE(Boost COMPONENTS system program_options REQUIRED)
include_directories(${PROJECT_SOURCE_DIR}/gicp)
include_directories(${PROJECT_SOURCE_DIR}/gicp/ann_1.1.1/include/ANN)
# G2O library
# Set up the top-level include directories
SET( G2O_INCLUDE ${PROJECT_SOURCE_DIR}/EXTERNAL/g2o CACHE PATH "Directory of G2O")
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR} ${G2O_INCLUDE})
# Add g2o lib dir
LINK_DIRECTORIES( ${LINK_DIRECTORIES} "${G2O_INCLUDE}/lib" )
#Generate config.h
configure_file(g2o/trunk/config.h.in ${PROJECT_BINARY_DIR}/g2o/config.h)
include_directories(${PROJECT_BINARY_DIR})
INSTALL(FILES ${PROJECT_BINARY_DIR}/g2o/config.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/g2o)
# Include the subdirectories
ADD_SUBDIRECTORY(g2o/trunk)
INCLUDE_DIRECTORIES(${CSPARSE_INCLUDE_DIR}) #You can use CPARSE or CHOLMOD
INCLUDE_DIRECTORIES(${CHOLMOD_INCLUDE_DIR})
set(G2O_DIR ${PROJECT_SOURCE_DIR}/g2o/trunk)
include_directories(${G2O_DIR})
link_directories(${G2O_DIR}/lib)
# Declare the target (an executable)
ADD_EXECUTABLE(Kinect6DSLAM kinect6DSLAM.cpp
./include/KinectGrabber.h
./include/KinectGrabber_OpenNI.h
./src/KinectGrabber_OpenNI.cpp
./include/KinectGrabber_Rawlog.h
./src/KinectGrabber_Rawlog.cpp
./include/KinectGrabber_Rawlog2.h
./src/KinectGrabber_Rawlog2.cpp
./include/KinectGrabber_MRPT.h
./src/KinectGrabber_MRPT.cpp
./include/VisualFeatureDescriptorExtractor.h
./include/VisualFeatureDescriptorExtractor_SURF_GPU.h
./include/VisualFeatureDescriptorExtractor_Generic.h
./include/VisualFeatureDescriptorExtractor_ORB.h
./include/VisualFeatureMatcher.h
./include/VisualFeatureMatcher_Generic.h
./include/PointCloudViewer.h
./include/PointCloudViewer_MRPT.h
./src/VisualFeatureDescriptorExtractor_SURF_GPU.cpp
./src/VisualFeatureDescriptorExtractor_Generic.cpp
./src/VisualFeatureDescriptorExtractor_ORB.cpp
./src/VisualFeatureMatcher_Generic.cpp
./src/PointCloudViewer_MRPT.cpp
./include/Visual3DRigidTransformationEstimator.h
./include/Visual3DRigidTransformationEstimator_SVD.h
./src/Visual3DRigidTransformationEstimator_SVD.cpp
./include/Visual3DRigidTransformationEstimator_RANSAC.h
./src/Visual3DRigidTransformationEstimator_RANSAC.cpp
./include/ICPPoseRefiner.h
./include/ICPPoseRefiner_PCL.h
./src/ICPPoseRefiner_PCL.cpp
./include/ICPPoseRefiner_StanfordGICP.h
./src/ICPPoseRefiner_StanfordGICP.cpp
./include/Miscellaneous.h
./src/Miscellaneous.cpp
./include/FrameRGBD.h
./src/FrameRGBD.cpp
./include/PointCloudDownsampler.h
./src/PointCloudDownsampler.cpp
./include/KeyframeLoopDetector.h
./src/KeyframeLoopDetector.cpp
./include/GraphOptimizer.h
./include/GraphOptimizer_MRPT.h
./src/GraphOptimizer_MRPT.cpp
./include/GraphOptimizer_G2O.h
./src/GraphOptimizer_G2O.cpp
./include/CKinect2DRawlog.h
./src/CKinect2DRawlog.cpp
)
TARGET_LINK_LIBRARIES(Kinect6DSLAM ${MRPT_LIBS}
${PCL_LIBRARIES}
${OpenCV_LIBS}
${Boost_LIBRARIES}
#GICP
${GSL_LIBRARIES}
${PROJECT_SOURCE_DIR}/gicp/ann_1.1.1/lib/libANN.a
${PROJECT_SOURCE_DIR}/gicp/libgicp.a
#G2O
core math_groups types_slam3d
solver_csparse #You can use CPARSE or CHOLMOD
solver_cholmod ${CHOLMOD_LIBRARIES}
)
# Declare the target (an executable)
ADD_EXECUTABLE(PairwiseAlignmentSteps PairwiseAlignmentSteps.cpp
./include/KinectGrabber.h
./include/KinectGrabber_OpenNI.h
./src/KinectGrabber_OpenNI.cpp
./include/KinectGrabber_Rawlog.h
./src/KinectGrabber_Rawlog.cpp
./include/KinectGrabber_MRPT.h
./src/KinectGrabber_MRPT.cpp
./include/VisualFeatureDescriptorExtractor.h
./include/VisualFeatureDescriptorExtractor_SURF_GPU.h
./include/VisualFeatureDescriptorExtractor_Generic.h
./include/VisualFeatureDescriptorExtractor_ORB.h
./include/VisualFeatureMatcher.h
./include/VisualFeatureMatcher_Generic.h
./include/PointCloudViewer.h
./include/PointCloudViewer_MRPT.h
./src/VisualFeatureDescriptorExtractor_SURF_GPU.cpp
./src/VisualFeatureDescriptorExtractor_Generic.cpp
./src/VisualFeatureDescriptorExtractor_ORB.cpp
./src/VisualFeatureMatcher_Generic.cpp
./src/PointCloudViewer_MRPT.cpp
./include/Visual3DRigidTransformationEstimator.h
./include/Visual3DRigidTransformationEstimator_SVD.h
./src/Visual3DRigidTransformationEstimator_SVD.cpp
./include/Visual3DRigidTransformationEstimator_RANSAC.h
./src/Visual3DRigidTransformationEstimator_RANSAC.cpp
./include/ICPPoseRefiner.h
./include/ICPPoseRefiner_PCL.h
./src/ICPPoseRefiner_PCL.cpp
./include/ICPPoseRefiner_StanfordGICP.h
./src/ICPPoseRefiner_StanfordGICP.cpp
./include/Miscellaneous.h
./src/Miscellaneous.cpp
./include/FrameRGBD.h
./src/FrameRGBD.cpp
./include/PointCloudDownsampler.h
./src/PointCloudDownsampler.cpp
)
TARGET_LINK_LIBRARIES(PairwiseAlignmentSteps ${MRPT_LIBS}
${PCL_LIBRARIES}
${OpenCV_LIBS}
${Boost_LIBRARIES}
#GICP
${GSL_LIBRARIES}
${PROJECT_SOURCE_DIR}/gicp/ann_1.1.1/lib/libANN.a
${PROJECT_SOURCE_DIR}/gicp/libgicp.a
)
# Set optimized building:
IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -mtune=native")
ENDIF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
target_link_libraries(Kinect6DSLAM ${LIBS})
Something tells me, that adding target_link_libraries(Kinect6DSLAM ${LIBS}) will help you.
Also, instead of constructs like
set(VAR ${VAR} somethingelse)
you can use this:
list(APPEND VAR somethingelse)