UPDATE
Aaaaaahm.. I just rewrote the namspaces (moved them into a utils-file) aaaaand now it builds and works ._.
So.. solved I guess?!
Though I'm still curios to whether I'm using cmake wrong or if it's fine the way I did it.
Would be nice if you'd let me know
Okay, I need help with cmake again *sigh* (I've wasted hours now and just can't get it to work the way I want)
PictureIt
Code:
PictureIt
├── CMakeLists.txt
├── depends
│ └── stb_image.h
├── include
│ └── pictureit
│ ├── effects
│ │ ├── crossfade.h
│ │ └── effects.h
│ ├── pictureit.h
│ └── spectrum.h
├── PictureItConfig.cmake.in
└── src
├── effects
│ ├── crossfade.cpp
│ └── effects.cpp
├── pictureit.cpp
└── spectrum.cpp
CMakeLists.txt
Code:
cmake_minimum_required(VERSION 2.6)
project(PictureIt)
enable_language(CXX)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
# Find and include OpenGL
find_package(OpenGL REQUIRED)
if(OPENGL_FOUND)
list(APPEND INCLUDES ${OpenGL_INCLUDE_DIRS})
list(APPEND DEPLIBS ${OPENGL_LIBRARIES})
add_definitions(${OpenGL_DEFINITIONS})
else(OPENGL_FOUND)
message(FATAL_ERROR "OpenGL not found!")
endif(OPENGL_FOUND)
list(APPEND INCLUDES ${PROJECT_SOURCE_DIR}/include)
list(APPEND INCLUDES ${PROJECT_SOURCE_DIR}/depends)
include_directories(${INCLUDES})
include_directories(${CMAKE_INCLUDE_PATH})
# Add all sources
file(GLOB_RECURSE SOURCES ${PROJECT_SOURCE_DIR}/src/*.cpp)
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/depends")
configure_file(PictureItConfig.cmake.in "${PROJECT_BINARY_DIR}/PictureItConfig.cmake" @ONLY)
# Enable pic
set(CMAKE_POSITION_INDEPENDENT_CODE 1)
add_library(PictureIt STATIC ${SOURCES})
set_property(TARGET PictureIt PROPERTY CXX_STANDARD 11)
PictureItConfig.cmake.in
Code:
# - Config file for the FooBar package
# It defines the following variables
# PICTUREIT_INCLUDE_DIRS - include directories for FooBar
# Compute paths
get_filename_component(PICTUREIT_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(PICTUREIT_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
This project builds just fine.
One
important note:
effects defines a namespace
PI_IMAGE which will be relevant later
Other Project using PictureIt (will be the kodi-addon as as soon as I get this thing to build)
Code:
Other Project
├── CMakeLists.txt
├── depends
│ └── PictureIt -> ../../PictureIt (I'm using a symlink because it makes development easier for now)
└── src
└── main.cpp
CMakeLists.txt
Code:
cmake_minimum_required(VERSION 2.6)
project(glut-pictureit)
enable_language(CXX)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
list(APPEND CMAKE_PREFIX_PATH ${PROJECT_BINARY_DIR}/depends)
# Find and include GLUT
find_package(GLUT REQUIRED)
if(GLUT_FOUND)
list(APPEND INCLUDES ${GLUT_INCLUDE_DIR})
list(APPEND DEPLIBS ${GLUT_LIBRARIES})
add_definitions(${GLUT_DEFINITIONS})
else(GLUT_FOUND)
message(FATAL_ERROR "GLUT not found!")
endif(GLUT_FOUND)
# Find and include OpenGL
find_package(OpenGL REQUIRED)
if(OPENGL_FOUND)
list(APPEND INCLUDES ${OpenGL_INCLUDE_DIRS})
list(APPEND DEPLIBS ${OPENGL_LIBRARIES})
add_definitions(${OpenGL_DEFINITIONS})
else(OPENGL_FOUND)
message(FATAL_ERROR "OpenGL not found!")
endif(OPENGL_FOUND)
# Include PictureIt
add_subdirectory(${PROJECT_SOURCE_DIR}/depends/PictureIt)
list(APPEND DEPLIBS PictureIt)
find_package(PictureIt CONFIG REQUIRED)
if(PictureIt_FOUND)
list(APPEND INCLUDES ${PICTUREIT_INCLUDE_DIRS})
else(PictureIt_FOUND)
message(FATAL_ERROR "PictureIt not found!")
endif(PictureIt_FOUND)
include_directories(${INCLUDES})
include_directories(${PROJECT_SOURCE_DIR})
add_executable(glut-pictureit src/main.cpp)
target_link_libraries(glut-pictureit ${DEPLIBS})
set_property(TARGET glut-pictureit PROPERTY CXX_STANDARD 11)
Build-Log
Code:
Scanning dependencies of target PictureIt
[ 14%] Building CXX object depends/PictureIt/CMakeFiles/PictureIt.dir/src/pictureit.cpp.o
[ 28%] Building CXX object depends/PictureIt/CMakeFiles/PictureIt.dir/src/effects/effects.cpp.o
[ 42%] Building CXX object depends/PictureIt/CMakeFiles/PictureIt.dir/src/effects/crossfade.cpp.o
[ 57%] Building CXX object depends/PictureIt/CMakeFiles/PictureIt.dir/src/spectrum.cpp.o
[ 71%] Linking CXX static library libPictureIt.a
[ 71%] Built target PictureIt
Scanning dependencies of target glut-pictureit
[ 85%] Building CXX object CMakeFiles/glut-pictureit.dir/src/main.cpp.o
[100%] Linking CXX executable glut-pictureit
depends/PictureIt/libPictureIt.a(pictureit.cpp.o): In function `PictureIt::render()':
pictureit.cpp:(.text+0x2fd): undefined reference to `PI_IMAGE::load(char const*, unsigned int)'
pictureit.cpp:(.text+0x33c): undefined reference to `PI_IMAGE::draw(unsigned int, float, float, float)'
pictureit.cpp:(.text+0x402): undefined reference to `PI_IMAGE::draw(unsigned int, float, float, float)'
depends/PictureIt/libPictureIt.a(crossfade.cpp.o): In function `EFXCrossfade::render(unsigned int, unsigned int)':
crossfade.cpp:(.text+0x14a): undefined reference to `PI_IMAGE::draw(unsigned int, float, float, float)'
crossfade.cpp:(.text+0x23a): undefined reference to `PI_IMAGE::draw(unsigned int, float, float, float)'
collect2: error: ld returned 1 exit status
CMakeFiles/glut-pictureit.dir/build.make:100: recipe for target 'glut-pictureit' failed
make[2]: *** [glut-pictureit] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/glut-pictureit.dir/all' failed
make[1]: *** [CMakeFiles/glut-pictureit.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
I have no idea what so every why that namespace isn't accessible.
I know that normally you'd install a lib to the system (including the headers) but I don't want that as the kodi visualisation addon has to work on its.
That's why I'm doing the "list(APPEND INCLUDES ${PICTUREIT_INCLUDE_DIRS})"
I really hope you guys can help me out again