CMake FIND_LIBRARY works on Windows but not OS X - c++

The same code ran on Cmake in windows finds the libraries, but on mac it cannot find them.The code finds the Include directories fine just not the libraries
Here is a screen of the Cmake output
And here is a Screen of the Directory structure
here is the CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project (GameCreatorEngine)
# version can be passed into the application from CMake TODO
set(cmake_test_VERSION_MAJOR 1)
set(cmake_test_VERSION_MINOR 3)
# compiler flags
add_definitions(
-c
-W4
)
# SDL LIB INCLUDES
SET( SDL2_SEARCH_PATHS
${SDL2_ROOT_DIR}
./res/lib/SDL2
)
FIND_PATH( SDL2_INCLUDE_DIRS
NAMES
SDL.h SDL2/SDL.h
PATHS
${SDL2_SEARCH_PATHS}
PATH_SUFFIXES
include
)
FIND_LIBRARY( SDL2
NAMES
SDL2.lib
PATHS
${SDL2_SEARCH_PATHS}
PATH_SUFFIXES
lib
)
FIND_LIBRARY( SDL2_MAIN
NAMES
SDL2main.lib
PATHS
${SDL2_SEARCH_PATHS}
PATH_SUFFIXES
lib
)
IF ( SDL2_INCLUDE_DIRS AND SDL2_MAIN AND SDL2)
SET( SDL2_FOUND TRUE )
MESSAGE(STATUS "Looking for SDL2 - found")
ELSE ( SDL2_INCLUDE_DIRS AND SDL2_MAIN AND SDL2 )
SET( SDL2_FOUND FALSE )
MESSAGE(STATUS "Looking for SDL2 - not found")
ENDIF ( SDL2_INCLUDE_DIRS AND SDL2_MAIN AND SDL2 )
# GLEW LIB INCLUDES
SET(GLEW_SEARCH_PATHS
${GLEW_ROOT_DIR}
./res/lib/GLEW
)
FIND_PATH( GLEW_INCLUDE_DIRS
NAMES
glew.h
PATHS
${GLEW_SEARCH_PATHS}
PATH_SUFFIXES
include
)
FIND_LIBRARY( GLEW_LIBRARIES
NAMES
glew32
PATHS
${GLEW_SEARCH_PATHS}
PATH_SUFFIXES
lib/Release/Win32
)
IF ( GLEW_INCLUDE_DIRS AND GLEW_LIBRARIES )
SET( GLEW_FOUND TRUE )
MESSAGE( STATUS "Looking for GLEW - found" )
ELSE ( GLEW_INCLUDE_DIRS AND GLEW_LIBRARIES )
SET( GLEW_FOUND FALSE )
MESSAGE( STATUS "Looking for GLEW - not found" )
ENDIF ( GLEW_INCLUDE_DIRS AND GLEW_LIBRARIES )
# ASSIMP
SET(ASSIMP_SEARCH_PATHS
${ASSIMP_ROOT_DIR}
./res/lib/assimp
)
FIND_PATH( ASSIMP_INCLUDE_DIRS
NAMES
mesh.h
PATHS
${ASSIMP_SEARCH_PATHS}
PATH_SUFFIXES
include
)
FIND_LIBRARY( ASSIMP_LIBRARIES
NAMES
assimp ASSIMP
PATHS
${ASSIMP_SEARCH_PATHS}
PATH_SUFFIXES
lib
lib/x86
lib/x64
)
IF ( ASSIMP_INCLUDE_DIRS AND ASSIMP_LIBRARIES )
SET( ASSIMP_FOUND TRUE )
MESSAGE(STATUS "Looking for ASSIMP - found")
ELSE ( ASSIMP_INCLUDE_DIRS AND ASSIMP_LIBRARIES )
SET( ASSIMP_FOUND FALSE )
MESSAGE(STATUS "Looking for ASSIMP - not found")
ENDIF ( ASSIMP_INCLUDE_DIRS AND ASSIMP_LIBRARIES )
# glm maths lib
SET( GLM_SEARCH_PATHS
${GLM_ROOT_DIR}
./res/lib/glm
)
FIND_PATH( GLM_INCLUDE_DIRS
NAMES
glm.hpp
PATHS
${GLM_SEARCH_PATHS}
PATH_SUFFIXES
include
)
IF ( GLM_INCLUDE_DIRS)
SET( GLM_FOUND TRUE )
MESSAGE(STATUS "Looking for GLM - found")
ELSE ( GLM_INCLUDE_DIRS )
SET( ASSIMP_FOUND FALSE )
MESSAGE(STATUS "Looking for GLM - not found")
ENDIF ( GLM_INCLUDE_DIRS )
# OpenGL
find_package(OpenGL REQUIRED)
# GameCreatorLibrary
file(GLOB HDRS ${ENGINE_SOURCE_DIR}src/*.h)
file(GLOB SRCS ${ENGINE_SOURCE_DIR}src/*.cpp src/*.c)
add_executable(GameCreatorEngine ${HDRS} ${SRCS})
# Define the include DIRs
include_directories(
${SDL2_INCLUDE_DIRS}
${GLEW_INCLUDE_DIRS}
${ASSIMP_INCLUDE_DIRS}
${GLM_INCLUDE_DIRS}
${OPENGL_INCLUDE_DIRS}
${ENGINE_SOURCE_DIR}/headers
${ENGINE_SOURCE_DIR}/sources
)
# Define the link libraries
target_link_libraries( GameCreatorEngine
${SDL2}
${SDL2_MAIN}
${GLEW_LIBRARIES}
${ASSIMP_LIBRARIES}
${OPENGL_LIBRARIES}
)

The proper filename extension for libraries varies on different platforms. While .lib is used for both static and dll import libraries on Windows, OS X uses different naming conventions (.a for static and .so/.dylib for dynamic libraries, possibly with a lib prefix).
In order to still allow code that works with all those different naming conventions, find_library expects you to omit any extensions or prefixes completely and just give the bare name of the library.
So instead of find_library(SDL2 NAMES SDL2.lib [...]) you should just write find_library(SDL2 NAMES SDL2 [...]).
From your question it also seems that you are trying to link your OS X build against Windows binaries (.lib and .dll file extensions). This will not work. You need a separate set of binaries compiled for OS X.

Related

I'm trying to SDL_DisplayFormat a .png file, I think, I may be missing a dependency

This is the function that gives me a segmentation fault dump,
it's the line:
optimizedImage = SDL_DisplayFormat( loadedImage );
Trying to build this on ubuntu Linux using codeblocks for my IDE.
I'm very close and want to use SDL mixers capability and png would be nice to have fully set up as well.
Just discovered the function may be deprecated. SDL_ConvertSurfaceFormat(); seems to be the replacement and is part of sdl2.. But i get an undefined error when I try it.. sdl and sdl2 appear to be linked properly.
SDL_Surface *load_image( std::string filename )
{
//The image that's loaded
cout<< "entered load image files"<< endl;
SDL_Surface* loadedImage = NULL;
//The optimized surface that will be used
SDL_Surface* optimizedImage = NULL;
//Load the image
loadedImage = IMG_Load( filename.c_str() );
cout<< "image image should be set"<< endl;
//If the image loaded
if( loadedImage != NULL )
{
cout<< "loaded image isn't null, hooray!"<< endl;
//Create an optimized surface
optimizedImage = SDL_DisplayFormat( loadedImage );
cout<< "optimized image should be in display format now"<< endl;
//Free the old surface
SDL_FreeSurface( loadedImage );
cout<< "sdl surface is free"<< endl;
//If the surface was optimized
if( optimizedImage != NULL )
{cout<< "optimized image is not null"<< endl;
//Color key surface
SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY, SDL_MapRGB( optimizedImage->format, 0, 0xFF, 0xFF ) );
cout<< "sdl setcolor key is ok"<< endl;
}
}
//Return the optimized surface
return optimizedImage;
}
Heres my cmakelists.text file
# CMake entry point
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(PNG REQUIRED)
find_package(ZLIB)
find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
add_definitions(${PNG_DEFINITIONS})
include_directories(${SDL2_INCLUDE_DIRS}
${SDL2_IMAGE_INCLUDE_DIRS})
include_directories(${PNG_INCLUDE_DIR})
find_path(PNG_INCLUDE_DIR png.h)
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
external/zlib-1.2.11/zlib.h
external/libpng-1.6.37/png.h
)
find_package(ZLIB)
if (ZLIB_FOUND)
include_directories(external/zlib-1.2.11)
#target_link_libraries(loaders ${ZLIB_LIBRARIES})
endif()
if (!PNG_FOUND)
message(STATUS "PNG not FOUND Don't use it")
endif()
if(!ZLIB_FOUND)
message(STATUS "ZLIB not FOUND")
endif()
include_directories(ZLIB external/zlib-1.2.11)
include_directories(PNG_INCLUDE_DIRS external/libpng-1.6.37)
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_directories(/usr/include)
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)
link_directories(/usr/include)
link_directories(external/libpng-1.6.37)
link_directories(ZLIB external/zlib-1.2.11)
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
)
target_link_libraries(loaders
-lSDLmain)
target_link_libraries(loaders
-lSDL)
target_link_libraries(loaders
-lSDL2_ttf)
target_link_libraries(loaders ${ZLIB_LIBRARIES})
target_link_libraries(loaders
-lSDL2_mixer)
target_link_libraries(loaders -zlib)
target_link_libraries(loaders ${PNG_LIBRARIES})
set_target_properties(loaders
PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(loaders ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
target_link_libraries(mageengine
${ALL_LIBS}
ANTTWEAKBAR_116_OGLCORE_GLFW
${SDL2_LIBRARIES}
loaders
)
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" )
i expect my program to not crash so I can further implement and debug code.
here's the output, repleat with cute but useful messages.
aaron#Zog:~/Desktop/maficengine/Mafic$ ./mageengine
LoadTexture object got constructed in mageengine from loadtexture.cpp
Reading image ./paint.bmp
Compiling shader : StandardShading.vertexshader
Compiling shader : StandardShading.fragmentshader
Linking program
Loading OBJ file plane.obj...
loadtexture() function works, inboundtexture is 1
ERROR(AntTweakBar) >> Parsing error in def string: Unknown attribute [true ...]
Compiling shader : StandardShading.vertexshader
Compiling shader : StandardShading.fragmentshader
Linking program
Loading OBJ file plane.obj...
passed sdl init everything
passed sdl init
entered load files
likely opened file background.png
entered load image files
image image should be set
loaded image isn't null, hooray!
Segmentation fault (core dumped)
the updated cmakelists.text after cleaning as advised in the comments below
# CMake entry point
cmake_minimum_required (VERSION 3.0)
project (maficengine LANGUAGES C CXX ASM)
set(CMAKE_MODULE_PATH "/home/aaron/Desktop/maficengine/cmake/")
find_package(PNG REQUIRED)
find_package(ZLIB REQUIRED)
find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL_image REQUIRED)# maybe sdl2_image
find_package(SDL_mixer REQUIRED)
#set(CMAKE_MODULE_PATH "/home/aaron/Desktop/maficengine/cmake/")
#et(SDL2_mixer_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
add_definitions(${PNG_DEFINITIONS})
include_directories(
${PNG_INCLUDE_DIRS}
${SDL2_INCLUDE_DIRS}
${SDL_MIXER_INCLUDE_DIR}
${SDL2_TTF_INCLUDE_DIRS}
${SDL_IMAGE_INCLUDE_DIRS}
${SDL2_IMAGE_INCLUDE_DIR}
)
file(GLOB_RECURSE SOURCE_FILES/usr/lib/x86_64-linux-gnu
${CMAKE_SOURCE_DIR}/src/*.c
${CMAKE_SOURCE_DIR}/src/*.cpp)
#include(FindSDL)
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()
#add_library(loaders
#external/myCustomHeaders/include/loadTexture.h
#external/myCustomHeaders/loadTexture.cpp
#)
if (ZLIB_FOUND)
include_directories(external/zlib-1.2.11)
message(STATUS "ZLIB FOUND")
elseif (!ZLIB_FOUND)
message(STATUS "Zlib not FOUND!")
endif()
if (PNG_FOUND)
message(STATUS "PNG FOUND ")
elseif (!PNG_FOUND)
message(STATUS "PNG not FOUND! ")
endif()
#if(SDL_FOUND)
# message(STATUS "sdl LIB FOUND!")
#elseif(!SDL_FOUND)
# message(STATUS "sdl LIB not FOUND!")
#endif()
if(SDL2_FOUND)
message(STATUS "sdl2 FOUND")
elseif(!SDL2_FOUND)
message(STATUS "sdl2 not FOUND!")
endif()
if(SDL_MIXER_FOUND)
message(STATUS "sdl mixer FOUND")
elseif(!SDL_MIXER_FOUND)
message(STATUS "sdl mixer not FOUND!")
endif()
if(SDL_IMAGE_FOUND)
message(STATUS "sdl image FOUND")
elseif(!SDL_IMAGE_FOUND)
message(STATUS "sdl image not FOUND!")
endif()
include_directories( external/myCustomHeaders/include )
include_directories(/usr/include)
include(FindPackageHandleStandardArgs)
#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)
link_directories(/usr/include)
link_directories(external/libpng-1.6.37)
link_directories(ZLIB external/zlib-1.2.11)
add_subdirectory (external)
# On Visual 2005 and above, this module can set the debug working directory
cmake_policy(SET CMP0026 OLD)
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
${SDL2_LIBRARIES}
${SDL2_IMAGE_LIBRARIES}
${SDL2_MIXER_LIBRARIES}
${SDL2_TTF_LIBRARIES}
)
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
)
target_link_libraries(mageengine
-lSDLmain)
target_link_libraries(mageengine
-lSDL)
# target_link_libraries(loaders
# -lSDL2_ttf)
#target_link_libraries(loaders ${ZLIB_LIBRARIES})
target_link_libraries(mageengine
-lSDL2_mixer)
#(loaders -zlib)
#target_link_libraries(loaders ${PNG_LIBRARIES})
set_target_properties(mageengine
PROPERTIES LINKER_LANGUAGE CXX)
#target_link_libraries(loaders ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
target_link_libraries(mageengine
${ALL_LIBS}
ANTTWEAKBAR_116_OGLCORE_GLFW
)
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/"
)
elseif (${CMAKE_GENERATOR} MATCHES "Xcode" )
endif (NOT ${CMAKE_GENERATOR} MATCHES "Xcode" )
Finally...tried SDL sound libraries for my game-engine again .... and found a way through!!!, good sound ...clear as a bell now, but i still think I will have to add sdl_mixer libraries to be satisfied. But this time I think I can do it. I found an old blog that sent me in the right direction. i think I installed SDL then upgraded to dev libraries, but it's the wrong order, then I couldn't purge the old library properly, but dug deeper and added tools to trace and destroy and finesse files and symbols till.. magic happened.. totally incredibly hard to do. Here's the blog that sent me the right way->
"If you built your own SDL, you probably didn't have development headers
for PulseAudio (or ALSA), so it's trying to use /dev/dsp, which doesn't
exist on many modern Linux systems (hence, SDL_Init(SDL_INIT_AUDIO)
succeeds, but no devices are found when you try to open one). "apt-get
install libasound2-dev libpulse-dev" and rebuild SDL...let the configure
script find the new headers so it includes PulseAudio and ALSA support. "

How do I install minizip with zlib?

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.

how to link re2 library in my project like a static library with cmake

My question: in this moment I'm linking the libre2 dinamically, but I want to do this statically. I installed the library in my pc (sudo apt-get install libre2-dev), got the "binary" and linked this binary "libre2.so" in my executable. But I want to git clone the repository or to do this by git submodule, then build this repository and link it in my project statically.
I'm new here and sorry for my bad English rss'
1) my project structure
- bin
- build
- external
- re2
- main.cpp
- CMakeLists.txt
- README.md
2) CMakeLists.txt
cmake_minimum_required( VERSION 2.6 )
project( simmc-agent )
# version number
set ( VERSION_MAJOR 0 )
set ( VERSION_MINOR 0 )
# cpr requires c++11
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
# src : main
file ( GLOB SOURCES *.cpp )
# linking res library dinamically
set(RE2_LIBRARIES -L${RE2_LIBRARY_DIR} -l libre2.so)
# src : collect functions - depend on OS
if ( WIN32 )
file ( GLOB SOURCES ${SOURCES} src/windows/*.cpp )
else () # if( UNIX )
file ( GLOB SOURCES ${SOURCES} src/linux/*.cpp )
endif ()
# headers
include_directories ( "include" )
# test
option( PRINT_JSON "Set to ON to print json objects before sending" OFF )
message(STATUS "${PRINT_JSON}: ${${PRINT_JSON}}")
if ( PRINT_JSON )
add_definitions ( -DPRINT_JSON )
endif ()
# compile
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY "../bin" )
add_executable ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} ${SOURCES} )
target_link_libraries ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} ${RE2_LIBRARY} )
3) main.cpp
#include <iostream>
#include <re2/re2.h>
using namespace std;
using namespace re2;
int main (int argc, char **argv) {
cout << "hello world" << endl;
int matchResult;
matchResult = RE2::FullMatch("hello", "h.*o");
cout << "matchResult = " << matchResult << endl;
return 0;
}
EDIT - (26.01.17) : Hello, guys. I'm here to talk how I resolve it.
Following some tips gave here, I create a file called re2.cmake:
cmake_minimum_required ( VERSION 2.8.7 )
if (NOT RE2_NAME)
include (ExternalProject)
SET (RE2_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/re2/src/re2/)
SET (RE2_EXTRA_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/re2/src/re2/)
SET (RE2_URL https://github.com/google/re2.git)
SET (RE2_BUILD ${CMAKE_BINARY_DIR}/re2/src/re2)
SET (RE2_LIBRARIES ${RE2_BUILD}/obj/so/libre2.so)
get_filename_component(RE2_STATIC_LIBRARIES ${RE2_BUILD}/libre2.a ABSOLUTE)
SET (RE2_INCLUDES ${RE2_BUILD})
if ( WIN32 )
SET (RE2_STATIC_LIBRARIES ${RE2_BUILD}/${CMAKE_BUILD_TYPE}/re2.lib)
else ()
SET (RE2_STATIC_LIBRARIES ${RE2_BUILD}/libre2.a)
endif ()
ExternalProject_Add(RE2
PREFIX RE2
GIT_REPOSITORY ${RE2_URL}
# GIT_TAG ${RE2_TAG}
DOWNLOAD_DIR "${DOWNLOAD_LOCATION}"
BUILD_IN_SOURCE 1
INSTALL_COMMAND sudo make install
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
)
## put re2 includes in the directory where they are expected
add_custom_target(re2_create_destination_dir COMMAND ${CMAKE_COMMAND} -E make_directory ${RE2_INCLUDE_DIR}/re2 DEPENDS re2)
add_custom_target(re2_copy_headers_to_destination DEPENDS re2_create_destination_dir)
foreach(header_file ${RE2_HEADERS})
add_custom_command(TARGET re2_copy_headers_to_destination PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${header_file} ${RE2_INCLUDE_DIR}/re2)
endforeach ()
ADD_LIBRARY(RE2_LIB STATIC IMPORTED DEPENDS RE2)
SET_TARGET_PROPERTIES(RE2_LIB PROPERTIES IMPORTED_LOCATION ${RE2_STATIC_LIBRARIES})
endif (NOT RE2_NAME)
This file download the repository, building and install the library libre2 in my computer. This library has a dependency for Thread library* (I thinks all linux operation system come with this library).
But, has a problem: I only do this, if I'm a root user. Because the library used the "make install" command and to do it, you need to be a root user.
my project structure:
- bin
- build
- src
- include
- modules
- re2.cmake
- CMakeLists.txt
FOllowing my CMakeLists.txt:
cmake_minimum_required ( VERSION 2.8.7 )
project ( project C CXX)
# version number
SET ( VERSION_MAJOR 0 )
SET ( VERSION_MINOR 0 )
SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
# src : main
file ( GLOB SOURCES src/main.cpp )
# headers
include_directories ( "include" )
# src : libre2 - Download, build and install the library
find_package (Threads)
include ( "modules/re2.cmake" )
set(RE2_STATIC_LIBRARIES -L${RE2_LIBRARY_DIR} -l libre2.a )
# 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} ${RE2_STATIC_LIBRARIES})
add_dependencies(project-v${VERSION_MAJOR}.${VERSION_MINOR} RE2)
target_link_libraries (project-v${VERSION_MAJOR}.${VERSION_MINOR} ${CMAKE_THREAD_LIBS_INIT})
My new CmakeLists.txt
cmake_minimum_required( VERSION 2.8.7 )
project( simmc-agent )
# version number
set ( VERSION_MAJOR 0 )
set ( VERSION_MINOR 0 )
# cpr requires c++11
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
# src : main
file ( GLOB SOURCES *.cpp )
# libre2
if (NOT RE2_NAME)
include (ExternalProject)
set(ABBREV "RE2")
set(EXT_PREFIX "external/re2" )
set(${ABBREV}_NAME ${ABBREV})
set(${ABBREV}_INCLUDE_DIRS ${EXT_PREFIX}/src/re2/)
set(APP_DEPENDENCIES ${APP_DEPENDENCIES} ${ABBREV})
message("Installing ${RE2_NAME} into ext build area: ${EXT_PREFIX} ...")
ExternalProject_Add(RE2
PREFIX ${EXT_PREFIX}
URL https://re2.googlecode.com/files/re2-20130115.tgz
URL_MD5 "ef66646926e6cb8f11f277b286eac579"
PATCH_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND make
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
)
set(CXXFLAGS CMAKE_CXX_FLAGS)
set(${ABBREV}_LIBRARIES ${EXT_PREFIX}/src/RE2/obj/so/libre2.so)
set(${ABBREV}_STATIC_LIBRARIES ${EXT_PREFIX}/src/RE2/obj/libre2.a)
set_target_properties(${RE2_NAME} PROPERTIES EXCLUDE_FROM_ALL ON)
endif (NOT RE2_NAME)
if(RE2_INCLUDE_DIRS AND RE2_LIBRARIES)
set(RE2_FOUND TRUE)
endif(RE2_INCLUDE_DIRS AND RE2_LIBRARIES)
if(RE2_FOUND)
message(STATUS "Found RE2: ${RE2_LIBRARIES}")
else(RE2_FOUND)
message(FATAL_ERROR "Could not find RE2 library.")
endif(RE2_FOUND)
set(INCLUDES ${INCLUDES} ${RE2_INCLUDE_DIRS} )
# set(LIBS ${LIBS} ${RE2_STATIC_LIBRARIES} )
# headers
include_directories ( "include" )
# test
option( PRINT_JSON "Set to ON to print json objects before sending" OFF )
message(STATUS "${PRINT_JSON}: ${${PRINT_JSON}}")
if ( PRINT_JSON )
add_definitions ( -DPRINT_JSON )
endif ()
# compile
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY "../bin" )
add_executable ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} ${SOURCES} )
target_link_libraries ( agent-v${VERSION_MAJOR}.${VERSION_MINOR} ${RE2_LIBRARIES})

Linker error using restbed

so, i'm trying to compile my program which has restbed as dependency.
I already compiled restbed with the following command:
cmake -DBUILD_TESTS=NO -DBUILD_SSL=YES -DBUILD_SHARED=NO
make -j4 install
Compiling restbed does not result in any errors.
Now the Problem:
I'm using the example source code from here: https://github.com/Corvusoft/restbed
This is my CMakeLists:
cmake_minimum_required (VERSION 2.6)
project(FDRService CXX)
# Setup
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_BINARY_DIR "./build")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
# FD Variables
set(FDRService_VERSION_MAJOR 1)
set(FDRService_VERSION_MINOR 0)
set(FDRService_INCLUDE_DIR "./include")
set(FDRService_SOURCE_DIR "./src")
# RestBED
set(RESTBED_ROOT "dependency/restbed/distribution")
set(RESTBED_INCLUDE_DIR "${RESTBED_ROOT}/include")
set(RESTBED_LIBRARY_DIR "${RESTBED_ROOT}/library")
# find all libraries
file(GLOB_RECURSE RESTBED_LIBRARY_FILES
"${RESTBED_LIBRARY_DIR}/*.a"
)
include_directories(${RESTBED_INCLUDE_DIR})
# find project source files
file(GLOB_RECURSE FDRService_FILES
"${FDRService_INCLUDE_DIR}/*.h"
"${FDRService_INCLUDE_DIR}/*.hpp"
"${FDRService_SOURCE_DIR}/*.c"
"${FDRService_SOURCE_DIR}/*.cpp"
)
add_executable(FDRService ${FDRService_FILES})
target_link_libraries(FDRService ${RESTBED_LIBRARY_FILES})
When i try to compile my project i get the following linker errors:
http://pastebin.com/hXPmAV2W (too much text for StackOverflow...)
My guess is that the OpenSSL library is not linked into the static .a file of restbed, but i put -DBUILD_SSL in the build command.
I hope anyone of you can help me with this problem. It's driving me crazy.
If you need more information, just tell me and i'll edit this post.
We use the following cmake modules to locate the necessary dependencies for projects reliant on Restbed.
Findrestbed.cmake
find_path( restbed_SOURCE CMakeLists.txt HINTS "${CMAKE_SOURCE_DIR}/dependency/restbed" )
if ( restbed_SOURCE )
set( restbed_FOUND TRUE )
set( restbed_BUILD "${CMAKE_CURRENT_BINARY_DIR}/restbed_build" )
set( restbed_DISTRIBUTION "${CMAKE_CURRENT_BINARY_DIR}/distribution" )
include( ExternalProject )
ExternalProject_Add( restbed SOURCE_DIR ${restbed_SOURCE}
PREFIX restbed_build
INSTALL_DIR ${restbed_DISTRIBUTION}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${restbed_DISTRIBUTION} -DBUILD_SSL=${BUILD_SSL} -DBUILD_SHARED=NO )
set( restbed_INCLUDE "${restbed_DISTRIBUTION}/include" )
set( restbed_LIBRARY "${restbed_DISTRIBUTION}/library/${CMAKE_STATIC_LIBRARY_PREFIX}restbed${CMAKE_STATIC_LIBRARY_SUFFIX}" )
message( STATUS "${Green}Found Restbed include at: ${restbed_SOURCE}${Reset}" )
else ( )
message( FATAL_ERROR "${Red}Failed to locate Restbed dependency.${Reset}" )
endif ( )
Findopenssl.cmake
find_library( ssl_LIBRARY ssl ssleay32 HINTS "${CMAKE_SOURCE_DIR}/dependency/restbed/dependency/openssl/out32dll" "${CMAKE_SOURCE_DIR}/dependency/restbed/dependency/openssl" "/usr/lib" "/usr/local/lib" "/opt/local/lib" )
find_library( crypto_LIBRARY crypto libeay32 HINTS "${CMAKE_SOURCE_DIR}/dependency/restbed/dependency/openssl/out32dll" "${CMAKE_SOURCE_DIR}/dependency/restbed/dependency/openssl" "/usr/lib" "/usr/local/lib" "/opt/local/lib" )
find_path( ssl_INCLUDE openssl/ssl.h HINTS "${CMAKE_SOURCE_DIR}/dependency/restbed/dependency/openssl/inc32" "${CMAKE_SOURCE_DIR}/dependency/restbed/dependency/openssl/include" "/usr/include" "/usr/local/include" "/opt/local/include" )
if ( ssl_INCLUDE AND ssl_LIBRARY AND crypto_LIBRARY )
set( OPENSSL_FOUND TRUE )
add_definitions( -DBUILD_SSL=TRUE )
if ( APPLE AND BUILD_SSL )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations" )
endif( )
message( STATUS "${Green}Found OpenSSL library at: ${ssl_LIBRARY}${Reset}" )
message( STATUS "${Green}Found OpenSSL include at: ${ssl_INCLUDE}${Reset}" )
message( STATUS "${Green}Found Crypto library at: ${crypto_LIBRARY}${Reset}" )
else ( )
message( FATAL_ERROR "${Red}Failed to locate OpenSSL dependency. see dependency/restbed/dependency/openssl; ./config shared; make all${Reset}" )
endif ( )
You can see an example of this in action at the RestQ GIT repository.

Error with the CMakeLists.txt in opencv project

I'm begining an opencv project in C++ and I figure that it'll be a nice occasion to learn some cmake. This is my project hirerachy:
project/
|__include/
|__sample1.h
|__sample2.h
|__build/
|__doc/
|__src/
|__sample1.cpp
|__sample2.cpp
|__test/
|__main.cpp
|__CMakeLists.txt
The CMakeLists.txt is :
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
SET( PROJ_NAME "Project" )
SET( PROJ_PATH ${CMAKE_SOURCE_DIR} )
SET( PROJ_OUT_PATH ${CMAKE_BINARY_DIR} )
SET( PROJ_LIBRARIES ${OpenCV_LIBS} )
SET( PROJ_INCLUDES "include" )
FILE( GLOB_RECURSE PROJ_SOURCES src/*cpp test/*cpp )
FILE( GLOB_RECURSE PROJ_HEADERS include/${PROJ_NAME}/*.h )
PROJECT( ${PROJ_NAME} )
FIND_PACKAGE( OpenCV REQUIRED )
INCLUDE_DIRECTORIES( ${PROJ_INCLUDES} )
ADD_EXECUTABLE( ${PROJ_NAME} ${PROJ_SOURCES} )
TARGET_LINK_LIBRARIES( ${PROJ_NAME} ${PROJ_LIBRARIES} )
The makefile is generated, but when I execute "make" I have some "undefined references" to opencv functions.
Any help would be appreciated, and of course if you want more information just ask :)
Thanks
SET( PROJ_LIBRARIES ${OpenCV_LIBS} )
OpenCV_LIBS will be set AFTER you search for the package with find_package().
You also need to add your headers to add_executable().