summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt76
1 files changed, 51 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7ed58af..b07eba7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,6 @@
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.1)
project(SDL_kitchensink C)
+include(GNUInstallDirs)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(KIT_VERSION_MAJOR "0")
@@ -12,47 +13,74 @@ add_definitions(
-DKIT_VERSION_PATCH=${KIT_VERSION_PATCH}
)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c99")
-set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -pedantic -Werror -fno-omit-frame-pointer")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
+set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -Werror -fno-omit-frame-pointer -Wno-deprecated-declarations")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ggdb -O2 -fno-omit-frame-pointer -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -DNDEBUG")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -Os -DNDEBUG")
option(BUILD_EXAMPLES "Build examples" OFF)
option(BUILD_TESTS "Build unittests" OFF)
+option(USE_DYNAMIC_LIBASS "Use dynamically loaded libass" ON)
find_package(SDL2)
-find_package(ass)
find_package(ffmpeg COMPONENTS avcodec avformat avutil swscale swresample)
-if(BUILD_TESTS)
- add_subdirectory(tests)
-endif()
-
-include_directories(
+set(LIBRARIES
+ ${SDL2_LIBRARIES}
+ ${FFMPEG_LIBRARIES}
+)
+set(INCLUDES
include/
${SDL2_INCLUDE_DIRS}
${FFMPEG_INCLUDE_DIRS}
- ${ASS_INCLUDE_DIRS}
)
-FILE(GLOB SOURCES "src/*.c")
-FILE(GLOB HEADERS "include/kitchensink/*.h")
+if(BUILD_TESTS)
+ add_subdirectory(tests)
+endif()
+
+if(USE_DYNAMIC_LIBASS)
+ if(WIN32 OR MINGW OR MSYS)
+ set(DYNAMIC_LIBASS_NAME "\"libass-9.dll\"")
+ else()
+ set(DYNAMIC_LIBASS_NAME "\"libass.so\"")
+ endif()
+ add_definitions(-DUSE_DYNAMIC_LIBASS)
+ add_definitions(-DDYNAMIC_LIBASS_NAME=${DYNAMIC_LIBASS_NAME})
+else()
+ find_package(ass)
+ set(LIBRARIES ${LIBRARIES} ${ASS_LIBRARIES})
+ set(INCLUDES ${INCLUDES} ${ASS_INCLUDE_DIRS})
+endif()
+
+FILE(GLOB_RECURSE SOURCES "src/*.c")
+FILE(GLOB INSTALL_HEADERS "include/kitchensink/*.h")
add_library(SDL_kitchensink SHARED ${SOURCES})
add_library(SDL_kitchensink_static STATIC ${SOURCES})
set_target_properties(SDL_kitchensink PROPERTIES VERSION ${KIT_VERSION})
set_target_properties(SDL_kitchensink PROPERTIES SOVERSION ${KIT_VERSION_MAJOR})
+
set_target_properties(SDL_kitchensink PROPERTIES DEBUG_POSTFIX "d")
set_target_properties(SDL_kitchensink_static PROPERTIES DEBUG_POSTFIX "d")
+
target_compile_definitions(SDL_kitchensink PRIVATE "KIT_DLL;KIT_DLL_EXPORTS")
target_compile_options(SDL_kitchensink PRIVATE "-fvisibility=hidden")
-target_link_libraries(SDL_kitchensink
- ${SDL2_LIBRARIES}
- ${FFMPEG_LIBRARIES}
- ${ASS_LIBRARIES}
+set_property(TARGET SDL_kitchensink PROPERTY C_STANDARD 99)
+set_property(TARGET SDL_kitchensink_static PROPERTY C_STANDARD 99)
+
+include_directories(${INCLUDES})
+target_link_libraries(SDL_kitchensink ${LIBRARIES})
+
+set(PKG_CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/SDL_kitchensink.pc")
+
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/pkg-config.pc.in"
+ ${PKG_CONFIG_FILE}
+ @ONLY
)
if(BUILD_EXAMPLES)
@@ -64,24 +92,22 @@ if(BUILD_EXAMPLES)
target_link_libraries(examplevideo mingw32)
endif()
+ set_property(TARGET exampleaudio PROPERTY C_STANDARD 99)
+ set_property(TARGET examplevideo PROPERTY C_STANDARD 99)
+
target_link_libraries(exampleaudio
SDL_kitchensink_static
- ${SDL2_LIBRARIES}
- ${FFMPEG_LIBRARIES}
- ${ASS_LIBRARIES}
+ ${LIBRARIES}
)
target_link_libraries(examplevideo
SDL_kitchensink_static
- ${SDL2_LIBRARIES}
- ${FFMPEG_LIBRARIES}
- ${ASS_LIBRARIES}
+ ${LIBRARIES}
)
endif()
# Installation
-include(GNUInstallDirs)
-
-INSTALL(FILES ${HEADERS} DESTINATION include/kitchensink/)
+install(FILES ${PKG_CONFIG_FILE} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+install(FILES ${INSTALL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/kitchensink)
INSTALL(TARGETS SDL_kitchensink SDL_kitchensink_static
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}