Wrong SDL_config.h when building SDL2 with cmake - cmake

I have been trying to add SDL2 to my project using CMake.
My CMakeLists.txt looks like this.
...
include_directories(
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/test
${PROJECT_SOURCE_DIR}/external
${PROJECT_SOURCE_DIR}/external/KHR
${PROJECT_SOURCE_DIR}/external/glm
${PROJECT_SOURCE_DIR}/external/nvToolsExt
${PROJECT_SOURCE_DIR}/external/stb_image
${PROJECT_SOURCE_DIR}/external/SDL2/include
${PROJECT_SOURCE_DIR}/external/assimp/include
)
# Setup dependencies
link_directories(
${PROJECT_SOURCE_DIR}/external/SDL2/lib/x64
${PROJECT_SOURCE_DIR}/external/assimp/lib
)
# Glad
add_subdirectory(external/glad)
# ImGui
add_subdirectory(external/imgui)
# Assimp
add_subdirectory(external/assimp ${EXECUTABLE_OUTPUT_PATH}/external/assimp)
# SDL2
add_subdirectory(external/SDL2 ${EXECUTABLE_OUTPUT_PATH}/external/SDL2)
# Setup build
set(TARGET_NAME sre)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${TARGET_NAME})
add_executable(${TARGET_NAME} ${SRC_FILES})
set_target_properties(sre PROPERTIES
VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
)
target_link_libraries(
${TARGET_NAME}
opengl32
SDL2Main
SDL2
glad
imgui
assimp
)
It generates the VS solution correctly but when I build it I get the following error from SDL2:
external\sdl2\include\sdl_config.h(52): fatal error C1189: #error: Wrong SDL_config.h, check your include path?
As a result, my build fails. I'm kind of a noob using cmake so any sort of advice is welcome.

Related

gtkmm 4.0 header build errors when compiling own project

I recently updated my gtkmm framework to version 4.0.0 and updated code to be compatible with the framework. I'm using msys2 in JetBrains CLion on Windows. However when I'm compiling project I got wall of warnings and errors in various framework headers like gtkmm, glibmm etc. I can't find errors which could be related to my code. Here is my Cmake configurations
cmake_minimum_required (VERSION 3.17.5)
set (CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS " -lstdc++fs")
project (Accounter)
find_package(Boost 1.73 COMPONENTS date_time REQUIRED)
FIND_LIBRARY (LIBZIP_LIBRARY NAMES zip)
FIND_PATH (LIBZIP_INCLUDE_DIR zip.h PATH_SUFFIXES include/zip include ) # Find header
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE(PkgConfig REQUIRED)
pkg_check_modules(GTKMM gtkmm-4.0)
include_directories( ${GTKMM_INCLUDE_DIRS} )
link_directories( ${GTKMM_LIBRARY_DIRS} )
#ADD_DEFINITIONS(${GTK_CFLAGS_OTHER})
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libzip DEFAULT_MSG LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR)
link_directories((Accounting))
add_subdirectory(Accounting)
link_directories(OdsFile)
add_subdirectory(OdsFile)
link_directories(GUI)
add_subdirectory(GUI)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(Accounter main.cpp)
target_link_libraries(Accounter LINK_PUBLIC Accounting OdsFile GUI ${Boost_LIBRARIES} ${LIBZIP_LIBRARY} stdc++fs ${GTKMM_LIBRARIES} )
else()
message( FATAL_ERROR "Boost library is required for this library")
ENDIF().
The compile log is under this link . Do I miss something in cmake configuration? How it should be compiled? I'll provide additional info, files if it will be required. I think errors should be on my side not on framework.

Include the CGAL shared libraries to deploy a CGAL program

I'm building a C++ program using CGAL, and I'm writing CMake install rules to deploy said program so that I can CPack the result and the end user doesn't have to install CGAL or any of its dependencies to use it. In order to do that, I need to include every shared library (DLLs on Windows etc) but I can't find a CMake variable that lets me do that. I searched around in the CGAL repo, but no luck. I tried using ${CGAL_LIBRARIES} but those don't give paths, and it doesn't seem like ${CGAL_LIBRARIES_DIRS} is a thing.
My current CMakeLists is based off the one generated by the dedicated CGAL script :
# Created by the script cgal_create_CMakeLists
# This is the CMake script for compiling a set of CGAL applications.
project( MeshCleaner )
cmake_minimum_required(VERSION 2.8.11)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# 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 )
if ( NOT Boost_FOUND )
message(STATUS "This project requires the Boost library, and will not be compiled.")
return()
endif()
# include for local directory
include_directories( BEFORE include )
# include for local package
# Creating entries for target: meshCleaner
# ############################
add_executable( ${PROJECT_NAME} main.cpp )
add_to_cached_list( CGAL_EXECUTABLE_TARGETS ${PROJECT_NAME} )
# Link the executable to CGAL and third-party libraries
target_link_libraries(${PROJECT_NAME} ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
install(TARGETS ${PROJECT_NAME} DESTINATION . COMPONENT Libraries)
message(${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES})
if(WIN32)
set(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)
endif()
include(${PROJECT_NAME}CPack)
The simplest way to "fix" that issue is to use CGAL as header-only. Please check the manual. Here is the direct link to the installation manual of CGAL-4.14, section "Header-only with CMake Configuration".

What are the function calls like `BCI2000_INCLUDE( "SOURCEFILTER" )` in CMake?

I want to compile the Emotiv EPOC module for BCI2000. In that module CMakeLists file contains following(below the following error log).
The compiler gives the following error,
-- Selecting Windows SDK version to target Windows 10.0.10586.
CMake Error at CMakeLists.txt:21 (BCI2000_INCLUDE):
Unknown CMake command "BCI2000_INCLUDE".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.10)```
CMakeLists.txt contains this,
###########################################################################
## $Id$
## Authors: griffin.milsap#gmail.com
## Description: Build information for the Emotiv module
# Set the executable name
SET( EXECUTABLE_NAME Emotiv )
# Set the project specific sources
SET( SRC_PROJECT
EmotivADC.cpp
lib/edk.imports.cpp
)
SET( HDR_PROJECT
EmotivADC.h
lib/edk.imports.h
)
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/lib/include )
BCI2000_INCLUDE( "SOURCEFILTER" )
IF( WIN32 )
# Create the signal source module
BCI2000_ADD_SIGNAL_SOURCE_MODULE(
"${EXECUTABLE_NAME}"
"${SRC_PROJECT}" "${HDR_PROJECT}"
"${CMAKE_CURRENT_SOURCE_DIR}/dll/edk.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/dll/edk_utils.dll"
)
ELSE()
MESSAGE( "--- No Emotiv libraries for this OS. Will not build." )
ENDIF()
How can I fix this?
Looks like they are function calls, but how do I import those function calls from another file if they are declared somewhere?
The project has to be compiled according to the instructions in this,
https://www.bci2000.org/mediawiki/index.php/Programming_Reference:Build_System
And it says the supported Visual Studio editions are 9(2008) and 10 only or you can compile it with CodeBlocks with MinGW.
And the supportive modules should be included into the source folder of BCI2000 and compile it as a whole project not as seperate modules. Then it recognized the functions defined in the parent project.
There are cMakeList files for submodules. But they cannot be compiled on their own.

How to solve:-1: error: No rule to make target `/home/xxxxx/opencv-3.0.0/lib/libopencv_xphoto.so.3.0.0', needed by `xxxxx'. Stop

I am trying to use cmake to compile code with OpenCV 3.0 in it. I tried to make it as simple as possible:
project(xxxxx)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
find_package(OpenCV)
message("Libs: ${OpenCV_LIBS}")
message("Include Dir: ${OpenCV_INCLUDE_DIRS}")
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(${PROJECT_NAME} ${SRC_LIST})
target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBS}
)
all I have in my main.cpp is:
#include <opencv2/core.hpp>
and
cv::UMat trqw;
I get the "No rule to make target" error. The error suggests that it is looking in the "opencv-3.0.0/lib/" folder which doesn't exist, it should be looking in the "opencv-3.0.0/build/lib/". Did I do something wrong when I built OpenCV that the CMAKE package looks in the wrong spot, and if not is there a better way for my CMakeLists.txt to direct it to look in the correct folder? I tried "${OPENCL_LIBRARIES}" in the target_link_libraries call and no change.
Thanks!
----edit----------------
yes, I did have find_package(OpenCV) in my cmakelists.txt as well, thanks! I've also tried find_package(OpenCV 3.0) and find_package(OpenCV 3.0 REQUIRED) with no avail.
----------edit---------------
output of
message("Libs: ${OpenCV_LIBS}") # I added it to the orig question
Libs: opencv_xphoto;opencv_xobjdetect;opencv_ximgproc;opencv_xfeatures2d;opencv_tracking;opencv_text;opencv_surface_matching;opencv_stereo;opencv_saliency;opencv_rgbd;opencv_reg;opencv_optflow;opencv_line_descriptor;opencv_face;opencv_dpm;opencv_datasets;opencv_ccalib;opencv_bioinspired;opencv_bgsegm;opencv_aruco;opencv_adas;opencv_world;opencv_videostab;opencv_videoio;opencv_video;opencv_superres;opencv_stitching;opencv_shape;opencv_photo;opencv_objdetect;opencv_ml;opencv_imgproc;opencv_imgcodecs;opencv_highgui;opencv_hal;opencv_flann;opencv_features2d;opencv_core;opencv_calib3d
Include Dir:
/home/xxxxx/opencv-3.0.0/build;/home/xxxxx/opencv-3.0.0/include;/home/xxxxx/opencv-3.0.0/include/opencv;/home/xxxxx/opencv-3.0.0/modules/hal/include;/home/xxxxx/opencv-3.0.0/modules/core/include;/home/xxxxx/opencv-3.0.0/modules/flann/include;/home/xxxxx/opencv-3.0.0/modules/imgproc/include;/home/xxxxx/opencv-3.0.0/modules/ml/include;/home/xxxxx/opencv-3.0.0/modules/photo/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/reg/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/surface_matching/include;/home/xxxxx/opencv-3.0.0/modules/video/include;/home/xxxxx/opencv-3.0.0/modules/imgcodecs/include;/home/xxxxx/opencv-3.0.0/modules/shape/include;/home/xxxxx/opencv-3.0.0/modules/videoio/include;/home/xxxxx/opencv-3.0.0/modules/highgui/include;/home/xxxxx/opencv-3.0.0/modules/objdetect/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/optflow/include;/home/xxxxx/opencv-3.0.0/modules/superres/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/tracking/include;/home/xxxxx/opencv-3.0.0/modules/ts/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/xobjdetect/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/xphoto/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/adas/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/bgsegm/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/bioinspired/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/dpm/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/face/include;/home/xxxxx/opencv-3.0.0/modules/features2d/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/line_descriptor/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/saliency/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/text/include;/home/xxxxx/opencv-3.0.0/modules/calib3d/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/ccalib/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/datasets/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/rgbd/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/stereo/include;/home/xxxxx/opencv-3.0.0/modules/stitching/include;/home/xxxxx/opencv-3.0.0/modules/videostab/include;/home/xxxxx/opencv-3.0.0/modules/world/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/xfeatures2d/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/ximgproc/include;/home/xxxxx/opencv-3.0.0/opencv_contrib-master/modules/aruco/include
Thanks to Tsyvarez for all the help!
set ( OpenCV_DIR "/home/xxxxx/opencv-3.0.0/build/")
before
find_package( OpenCV 3.0 REQUIRED)
in cmakelists.txt
Thanks!

adding xapian library in cmake

I am trying to add xapian search engine library in cmake file
project(search)
cmake_minimum_required(VERSION 2.8)
find_package(Xapian REQUIRED)
aux_source_directory(. SRC_LIST)
target_link_libraries(${PROJECT_NAME}
${Xapian_LIBRARY}
)
add_executable(${PROJECT_NAME} ${SRC_LIST})
This is not working can any one tell me how to add this if i compile with -lxapian it works
Swap target_link_libraries() and add_executable() calls. You can link library only to already defined target.
And use ${XAPIAN_LIBRARIES} instead of ${Xapian_LIBRARY}.