Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
dumb workaround for old cmake that can't set include_directories per
Browse files Browse the repository at this point in the history
target
  • Loading branch information
scorpp committed Mar 10, 2013
1 parent 4a7cb34 commit e1947c1
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,33 @@ include_directories(${DB_VK_SOURCE_DIR})

set(CMAKE_C_FLAGS "-g -Wall")


# Older versions of cmake does not support modifying INCLUDE_DIRECTORIES for a target
# by means of SET_TARGET_PROPERTIES command
if (CMAKE_MAJOR_VERSION EQUAL "2"
AND (CMAKE_MINOR_VERSION LESS "8" OR CMAKE_MINOR_VERSION EQUAL "8")
AND CMAKE_PATCH_VERSION LESS "10")
set(CMAKE_PRIOR_TO_2_8_10 "ON")
endif()
# With this old version we can't build two versions at the same time :(
if (CMAKE_PRIOR_TO_2_8_10 AND WITH_GTK2 AND WITH_GTK3)
message(FATAL_ERROR "Cannot build both GTK2 & GTK3 libs at once on cmake ${CMAKE_VERSION}. Build with either version of GTK separately (e.g. -DWITH_GTK2=ON -DWITH_GTK3=OFF) or upgrade cmake to at least 2.8.10")
endif()


if (WITH_GTK2)
pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
add_library(vkontakte_gtk2 SHARED vkontakte.c vk-api.c ui.c util.c)
target_link_libraries(vkontakte_gtk2 ${GTK2_LIBRARIES} ${CURL_LIBRARIES} ${JSON_GLIB_LIBRARIES})

get_target_property(VK_GTK2_INCLUDE_DIRS vkontakte_gtk2 INCLUDE_DIRECTORIES)
set_target_properties(vkontakte_gtk2 PROPERTIES INCLUDE_DIRECTORIES "${VK_GTK2_INCLUDE_DIRS};${GTK2_INCLUDE_DIRS}")
if (CMAKE_PRIOR_TO_2_8_10)
include_directories(${GTK2_INCLUDE_DIRS})
else()
get_target_property(VK_GTK2_INCLUDE_DIRS vkontakte_gtk2 INCLUDE_DIRECTORIES)
set_target_properties(vkontakte_gtk2 PROPERTIES INCLUDE_DIRECTORIES "${VK_GTK2_INCLUDE_DIRS};${GTK2_INCLUDE_DIRS}")
endif()

link_directories(${GTK2_LIBRARY_DIRS})
link_directories(${GTK2_LIBRARY_DIRS})

set_target_properties(vkontakte_gtk2 PROPERTIES PREFIX "")
install(TARGETS vkontakte_gtk2 DESTINATION "lib${LIB_SUFFIX}/deadbeef")
Expand All @@ -36,8 +54,12 @@ if (WITH_GTK3)
add_library(vkontakte_gtk3 SHARED vkontakte.c vk-api.c ui.c util.c)
target_link_libraries(vkontakte_gtk3 ${GTK3_LIBRARIES} ${CURL_LIBRARIES} ${JSON_GLIB_LIBRARIES})

get_target_property(VK_GTK3_INCLUDE_DIRS vkontakte_gtk3 INCLUDE_DIRECTORIES)
set_target_properties(vkontakte_gtk3 PROPERTIES INCLUDE_DIRECTORIES "${VK_GTK3_INCLUDE_DIRS};${GTK3_INCLUDE_DIRS}")
if (CMAKE_PRIOR_TO_2_8_10)
include_directories(${GTK3_INCLUDE_DIRS})
else()
get_target_property(VK_GTK3_INCLUDE_DIRS vkontakte_gtk3 INCLUDE_DIRECTORIES)
set_target_properties(vkontakte_gtk3 PROPERTIES INCLUDE_DIRECTORIES "${VK_GTK3_INCLUDE_DIRS};${GTK3_INCLUDE_DIRS}")
endif()

link_directories(${GTK2_LIBRARY_DIRS})

Expand Down

0 comments on commit e1947c1

Please sign in to comment.