Skip to content

Commit

Permalink
Add static build option (#9)
Browse files Browse the repository at this point in the history
* cmake dependencies

* 🙊 optimized CMakeList.txt
  • Loading branch information
Flask authored and Stefan Reinhard committed Nov 20, 2017
1 parent f09b7f3 commit f2c4f94
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 233 deletions.
42 changes: 31 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.5)

project(tifig)
set(PACKAGE "tifig")
project(${PACKAGE})

set(CMAKE_CXX_STANDARD 11)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH})

find_package(LibAV REQUIRED)
find_package(PkgConfig)
pkg_search_module(VIPS REQUIRED vips-cpp)

#set(CMAKE_VERBOSE_MAKEFILE ON)

if(NOT CMAKE_BUILD_TYPE)
Expand All @@ -18,6 +12,31 @@ endif()

set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wno-implicit-fallthrough")

option(STATIC_BUILD "Build tifig static")

if (STATIC_BUILD)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s -static-libstdc++")
set(BUILD_SHARED_LIBS OFF)
set(BUILD_STATIC_LIBS ON)
endif()

find_package(PkgConfig)

pkg_check_modules(AVCODEC libavcodec REQUIRED)
pkg_check_modules(AVUTIL libavutil REQUIRED)
pkg_check_modules(SWSCALE libswscale REQUIRED)
pkg_check_modules(VIPS vips-cpp REQUIRED)


set(TIFIG_INCLUDE_DIRS "${AVCODEC_INCLUDE_DIRS} ${AVUTIL_INCLUDE_DIRS} ${SWSCALE_INCLUDE_DIRS} ${VIPS_INCLUDE_DIRS}")

if (STATIC_BUILD)
set(TIFIG_PKG_LIBS "${AVCODEC_STATIC_LDFLAGS} ${AVUTIL_STATIC_LDFLAGS} ${SWSCALE_STATIC_LDFLAGS} ${VIPS_STATIC_LDFLAGS}")
else()
set(TIFIG_PKG_LIBS "${AVCODEC_LDFLAGS} ${AVUTIL_LDFLAGS} ${SWSCALE_LDFLAGS} ${VIPS_LDFLAGS}")
endif()


set(LIBHEIF_DIR ${PROJECT_SOURCE_DIR}/lib/heif)
set(SOURCE_FILES
src/main.cpp
Expand All @@ -33,7 +52,8 @@ include_directories(${LIBHEIF_DIR}/Srcs/common)
include_directories(${LIBHEIF_DIR}/Srcs/reader)
include_directories(lib/cxxopts/include)
include_directories(lib/easyexif)
include_directories(${VIPS_INCLUDE_DIRS})

target_link_libraries(${TIFIG} heifreader cxxopts)
target_link_libraries(${TIFIG} ${VIPS_CFLAGS} ${VIPS_LDFLAGS} ${LIBAV_LIBRARIES} pthread)
include_directories(${TIFIG_INCLUDE_DIRS})

target_link_libraries(${TIFIG} heifreader cxxopts pthread)
target_link_libraries(${TIFIG} ${TIFIG_PKG_LIBS})
222 changes: 0 additions & 222 deletions FindLibAV.cmake

This file was deleted.

0 comments on commit f2c4f94

Please sign in to comment.