Error with the CMakeLists.txt in opencv project - c++

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().

Related

Using Cspice with mingw

I am trying to use cspice with g++ for windows via mingw. Unfortunately cspice does not provide a library for mingw. The libraries are available at https://naif.jpl.nasa.gov/naif/toolkit_C.html.
It gives undefined reference errors for the functions defined through cspice. It runs properly in Linux.
Can anyone suggest a method to make it work.
I run:
g++ -LK:\Data\cspice\lib -IF:\CPP\Libraries\Boost\boost_1_68_0 -o foo foo.cpp -l:cspice.a -lm
The errors I get are:
undefined reference to 'furnsh_c'
and other functions I use from 'SpiceUsr.h'.
Am I not linking the file properly or what is the error.
I managed to compile this in windows using MinGW.
I downloaded the code from NASA website for UNIX not WINDOWS.
You need to download a libf2c library, the arith.h (comment this line //#include <config.h>) header and the times.h header.
Then I use the following CMakeLists.txt with MinGW and CMAKE for windows.
mkdir build
cd build
cmake .. -G "MinGW Makefiles"
mingw32-make
Some compilation errors will came out but they are very straightforward to solve.
# CMAKE version and project name
cmake_minimum_required( VERSION 2.8.11 )
project( cspice )
# Add preprocessor directives
SET( GCC_COVERAGE_COMPILE_FLAGS "-c -ansi -m64 -O2 -fPIC -DNON_UNIX_STDIO" )
#SET( GCC_COVERAGE_LINK_FLAGS "-lf2c -lm" )
#SET( GCC_COVERAGE_LINK_FLAGS "-lf2c" )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}" )
# Include directories
include_directories( include
libf2c )
file( GLOB f2c_src "libf2c/*.c" )
file( GLOB f2c_headers "libf2c/*.h" )
file( GLOB csupport_src "src/csupport/*.c" )
file( GLOB csupport_headers "src/csupport/*.h" )
file( GLOB brief_src "src/brief_c/*.c" )
file( GLOB chronos_src "src/chrnos_c/*.c" )
file( GLOB ckbrief_src "src/ckbref_c/*.c" )
file( GLOB commnt_src "src/commnt_c/*.c" )
file( GLOB dskbrief_src "src/dskbrief_c/*.c" )
file( GLOB dskexp_src "src/dskexp_c/*.c" )
file( GLOB frmdiff_src "src/frmdif_c/*.c" )
file( GLOB inspekt_src "src/inspkt_c/*.c" )
file( GLOB mkdsk_src "src/mkdsk_c/*.c" )
file( GLOB mkspk_src "src/mkspk_c/*.c" )
file( GLOB msopck_src "src/msopck_c/*.c" )
file( GLOB spacit_src "src/spacit_c/*.c" )
file( GLOB spkdiff_src "src/spkdif_c/*.c" )
file( GLOB spkmerge_src "src/spkmrg_c/*.c" )
file( GLOB tobin_src "src/tobin_c/*.c" )
file( GLOB toxfr_src "src/toxfr_c/*.c" )
file( GLOB version_src "src/versn_c/*.c" )
file( GLOB cspice_src "src/cspice/*.c" )
file( GLOB cspice_headers "include/*.h" )
# Libraries
add_library( f2c ${f2c_src} ${f2c_header} )
add_library( csupport ${csupport_src} ${csupport_header} )
add_library( brief ${brief_src} )
add_library( chronos ${chronos_src} )
add_library( ckbrief ${ckbrief_src} )
add_library( commnt ${commnt_src} )
add_library( dskbrief ${dskbrief_src} )
add_library( dskexp ${dskexp_src} )
add_library( frmdiff ${frmdiff_src} )
add_library( inspekt ${inspekt_src} )
add_library( mkdsk ${mkdsk_src} )
add_library( mkspk ${mkspk_src} )
add_library( msopck ${msopck_src} )
add_library( spacit ${spacit_src} )
add_library( spkdiff ${spkdiff_src} )
add_library( spkmerge ${spkmerge_src} )
add_library( tobin ${tobin_src} )
add_library( toxfr ${toxfr_src} )
add_library( version ${version_src} )
add_library( cspice ${cspice_src} ${cspice_headers} )
# Executable
add_executable( simple src/cook_c/simple.c )
add_executable( states src/cook_c/states.c )
add_executable( subpt src/cook_c/subpt.c )
add_executable( tictoc src/cook_c/tictoc.c )
# Link the executable and libraries
target_link_libraries ( f2c )
target_link_libraries ( csupport f2c )
target_link_libraries ( brief f2c )
target_link_libraries ( chronos f2c )
target_link_libraries ( ckbrief f2c )
target_link_libraries ( commnt f2c )
target_link_libraries ( dskbrief f2c )
target_link_libraries ( dskexp f2c )
target_link_libraries ( frmdiff f2c )
target_link_libraries ( inspekt f2c )
target_link_libraries ( mkdsk f2c )
target_link_libraries ( mkspk f2c )
target_link_libraries ( msopck f2c )
target_link_libraries ( spacit f2c )
target_link_libraries ( spkdiff f2c )
target_link_libraries ( spkmerge f2c )
target_link_libraries ( tobin f2c )
target_link_libraries ( toxfr f2c )
target_link_libraries ( version f2c )
target_link_libraries ( cspice brief chronos ckbrief commnt dskbrief dskexp frmdiff inspekt mkdsk mkspk msopck spacit spkdiff spkmerge tobin toxfr version )
target_link_libraries ( simple cspice )
target_link_libraries ( states cspice )
target_link_libraries ( subpt cspice )
target_link_libraries ( tictoc cspice )

CMakeList.txt set up for restbed

I am fairly new to CMake and using C++ Frameworks and have trouble setting up my project. When I try to build it I get the following error
/Users/adjust/Documents/C++/WebService/main.cpp:7:10: fatal error: 'restbed' file not found
I cloned the restbed repo into my project folder WebService. The Build was no problem, in restbed.build make test succeeded to 100%.
Troubleshooting the issue did not lead to success (yet) so I hope that maybe with a solution to my answer other newbies might be helped in the future as well.
I am using CLion on OS X and my CMakeList.txt file as followed.
cmake_minimum_required(VERSION 3.7)
project(WebService)
#Set Version
set (WebService_VERSION_MAJOR 1)
set (WebService_VERSION_MAJOR 0)
#Setup Asio
find_path( asio_INCLUDE asio.hpp HINTS "${PROJECT_SOURCE_DIR}/dependency/asio/asio/include" "/usr/include" "/usr/local/include" "/opt/local/include" )
if ( asio_INCLUDE )
set( ASIO_FOUND TRUE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DASIO_STANDALONE=YES" )
message( STATUS "${Green}Found ASIO include at: ${asio_INCLUDE}${Reset}" )
else ( )
message( FATAL_ERROR "${Red}Failed to locate ASIO dependency.${Reset}" )
endif ( )
set(CMAKE_CXX_STANDARD 11)
#Setup OpenSSl
find_library( ssl_LIBRARY ssl ssleay32 HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/out32dll" "${PROJECT_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" )
find_library( crypto_LIBRARY crypto libeay32 HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/out32dll" "${PROJECT_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" )
find_path( ssl_INCLUDE openssl/ssl.h HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/inc32" "${PROJECT_SOURCE_DIR}/dependency/openssl/include" "/usr/local/opt/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 restbed/dependency/openssl; ./config shared; make all${Reset}" )
endif ( )
# RestBED
set( restbed_SOURCE "${PROJECT_SOURCE_DIR}/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" )
set( restbed_INCLUDE "${restbed_DISTRIBUTION}/include" )
set( restbed_LIBRARY "${restbed_DISTRIBUTION}/library" )
message( STATUS "${Green}Found Restbed include at: ${restbed_SOURCE}${Reset}" )
else ( )
message( FATAL_ERROR "${Red}Failed to locate Restbed dependency.${Reset}" )
endif ( )
# find all files from restbed library
file(GLOB_RECURSE restbed_LIBRARY_FILES
"${restbed_LIBRARY}/*.a")
include_directories(${restbed_INCLUDE})
add_executable(WebService main.cpp)
target_link_libraries(WebService ${restbed_LIBRARY_FILES})
I understood that I need only the library and include of the distribution folder. What am I doing wrong?
EDIT:
I found the mistake, simply make sure that you are setting the path actual directory, here is the solution:
cmake_minimum_required(VERSION 3.7)
project(WebService)
#Set Version
set (WebService_VERSION_MAJOR 1)
set (WebService_VERSION_MAJOR 0)
set(CMAKE_CXX_STANDARD 11)
#Setup Asio
find_path( asio_INCLUDE asio.hpp HINTS "${PROJECT_SOURCE_DIR}/dependency/asio/asio/include" "/usr/include" "/usr/local/include" "/opt/local/include" )
if ( asio_INCLUDE )
set( ASIO_FOUND TRUE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DASIO_STANDALONE=YES" )
message( STATUS "${Green}Found ASIO include at: ${asio_INCLUDE}${Reset}" )
else ( )
message( FATAL_ERROR "${Red}Failed to locate ASIO dependency.${Reset}" )
endif ( )
#Setup OpenSSl
find_library( ssl_LIBRARY ssl ssleay32 HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/out32dll" "${PROJECT_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" )
find_library( crypto_LIBRARY crypto libeay32 HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/out32dll" "${PROJECT_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" )
find_path( ssl_INCLUDE openssl/ssl.h HINTS "${PROJECT_SOURCE_DIR}/dependency/openssl/inc32" "${PROJECT_SOURCE_DIR}/dependency/openssl/include" "/usr/local/opt/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 restbed/dependency/openssl; ./config shared; make all${Reset}" )
endif ( )
# RestBED
find_path( restbed_SOURCE "${PROJECT_SOURCE_DIR}/restbed" )
if ( restbed_SOURCE )
#set( restbed_FOUND TRUE )
set( restbed_BUILD "${CMAKE_CURRENT_BINARY_DIR}/restbed_build" )
set( restbed_DISTRIBUTION "${restbed_SOURCE}/distribution" )
set( restbed_INCLUDE "${restbed_DISTRIBUTION}/include" )
set( restbed_LIBRARY "${restbed_DISTRIBUTION}/library" )
message( STATUS "${Green}Found Restbed include at: ${restbed_INCLUDE}${Reset}" )
else ( )
message( FATAL_ERROR "${Red}Failed to locate Restbed dependency.${Reset}" )
endif ( )
# find all files from restbed library
file(GLOB_RECURSE restbed_LIBRARY_FILES
"${restbed_LIBRARY}/*.a")
include_directories(${restbed_INCLUDE})
#add_executable(WebService ${SOURCE_FILES})
add_executable(WebService main.cpp)
target_link_libraries(WebService ${restbed_LIBRARY_FILES})

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.

CMake FIND_LIBRARY works on Windows but not OS X

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.

How to set CMAKE_INTDIR or CMAKE_CFG_INTDIR to remove the project configuration?

Now I am using CMake to create a VC 10 project. One issue I have found is that the path of the output library or execute program is connected with the project configuration (debug or release). In order to illustrate it, I give the following examples:
cmake_minimum_required( VERSION 2.6 )
project (test)
add_definitions (-DEXP_STL )
add_library(lib1 SHARED lib1.cxx)
set_target_properties(lib1 PROPERTIES LINK_INTERFACE_LIBRARIES "")
set(LIBRARY_OUTPUT_PATH ${test_SOURCE_DIR})
The last command in the script denote that I would like to put the output library (lib1) in the directory of ${test_SOURCE_DIR}. However, the output library is located in ${test_SOURCE_DIR}/Debug instead. I was wondering how I could make sure that the output library is exactly in the path I have set. Thanks!
BWT: The reason why I raise this question is because in the Linux development environmental the output library or execute program path is exactly the path you set with set(LIBRARY_OUTPUT_PATH ...) function. I want to have a consistent result.
This question is regarded as duplicated, and one possible solution is as follows:
if (WIN32)
set(myoutputdirectory ${your_source_file_SOURCE_DIR}/output/win/32)
elseif (CMAKE_COMPILER_IS_GNUCC)
set(myoutputdirectory ${your_source_file_SOURCE_DIR}/output/linux/32)
elseif(APPLE)
set(myoutputdirectory ${your_source_file_SOURCE_DIR}/output/mac/32)
endif (WIN32)
# set output parth
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${myoutputdirectory} )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${myoutputdirectory} )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${myoutputdirectory} )
# for multi-config builds (e.g. msvc)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${myoutputdirectory} )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${myoutputdirectory} )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${myoutputdirectory} )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )