Shared cmark library

Making optional linking with shared system cmark library with
-DUSE_SHARED_CMARK option.
This commit is contained in:
Azamat H. Hackimov 2017-01-28 16:18:41 +05:00
parent 7c6d927eb1
commit 90624bbc22
3 changed files with 29 additions and 21 deletions

View File

@ -57,6 +57,7 @@ option(WITH_DESKTOP_INTEGRATION "Enable desktop integration modules" off)
option(WITH_QT_THUMBNAILER "Enable kde5/qt5 thumnailer" off) option(WITH_QT_THUMBNAILER "Enable kde5/qt5 thumnailer" off)
option(USE_STATIC_LIBC "Use static version of C and C++ runtimes" off) option(USE_STATIC_LIBC "Use static version of C and C++ runtimes" off)
option(USE_SHARED_CMARK "Use your installed copy of cmark" off)
option(USE_SHARED_CURL "Use your installed copy of curl" off) option(USE_SHARED_CURL "Use your installed copy of curl" off)
option(USE_SHARED_GIFLIB "Use your installed copy of giflib" off) option(USE_SHARED_GIFLIB "Use your installed copy of giflib" off)
option(USE_SHARED_JPEGLIB "Use your installed copy of jpeglib" off) option(USE_SHARED_JPEGLIB "Use your installed copy of jpeglib" off)
@ -135,6 +136,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_PROFILE "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_PROFILE "${CMAKE_BINARY_DIR}/lib") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_PROFILE "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_PROFILE "${CMAKE_BINARY_DIR}/bin") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_PROFILE "${CMAKE_BINARY_DIR}/bin")
set(CMARK_DIR ${CMAKE_SOURCE_DIR}/third_party/cmark)
set(CURL_DIR ${CMAKE_SOURCE_DIR}/third_party/curl) set(CURL_DIR ${CMAKE_SOURCE_DIR}/third_party/curl)
set(GIFLIB_DIR ${CMAKE_SOURCE_DIR}/third_party/giflib) set(GIFLIB_DIR ${CMAKE_SOURCE_DIR}/third_party/giflib)
set(LIBJPEG_DIR ${CMAKE_SOURCE_DIR}/third_party/jpeg) set(LIBJPEG_DIR ${CMAKE_SOURCE_DIR}/third_party/jpeg)
@ -290,6 +292,14 @@ if(USE_ALLEG4_BACKEND)
include_directories(${LOADPNG_INCLUDE_DIR}) include_directories(${LOADPNG_INCLUDE_DIR})
endif() endif()
if(USE_SHARED_CMARK)
find_library(CMARK_LIBRARIES NAMES cmark)
find_path(CMARK_INCLUDE_DIRS NAMES cmark.h)
else()
add_definitions(-DCMARK_STATIC_DEFINE)
set(CMARK_LIBRARIES libcmark_static)
endif()
if(USE_SHARED_CURL) if(USE_SHARED_CURL)
find_package(CURL REQUIRED) find_package(CURL REQUIRED)
else() else()

View File

@ -60,10 +60,6 @@ if(WITH_WEBP_SUPPORT)
add_definitions(-DASEPRITE_WITH_WEBP_SUPPORT) add_definitions(-DASEPRITE_WITH_WEBP_SUPPORT)
endif() endif()
# cmark include files
add_definitions(-DCMARK_STATIC_DEFINE)
include_directories(${CMAKE_BINARY_DIR}/third_party/cmark)
###################################################################### ######################################################################
# app-lib target # app-lib target
@ -476,7 +472,7 @@ target_link_libraries(app-lib
she she
ui-lib ui-lib
undo undo
libcmark_static ${CMARK_LIBRARIES}
${TINYXML_LIBRARY} ${TINYXML_LIBRARY}
${JPEG_LIBRARIES} ${JPEG_LIBRARIES}
${GIF_LIBRARIES} ${GIF_LIBRARIES}

View File

@ -88,19 +88,21 @@ endif()
add_subdirectory(simpleini) add_subdirectory(simpleini)
# Add cmark without tests # Add cmark without tests
set(CMARK_TESTS OFF CACHE BOOL "Build cmark tests and enable testing") if(NOT USE_SHARED_CMARK)
add_subdirectory(cmark) set(CMARK_TESTS OFF CACHE BOOL "Build cmark tests and enable testing")
set(cmark_headers add_subdirectory(cmark)
${CMAKE_CURRENT_SOURCE_DIR}/cmark/src/cmark.h set(cmark_headers
${CMAKE_CURRENT_BINARY_DIR}/cmark/src/cmark_export.h ${CMAKE_CURRENT_SOURCE_DIR}/cmark/src/cmark.h
${CMAKE_CURRENT_BINARY_DIR}/cmark/src/cmark_version.h) ${CMAKE_CURRENT_BINARY_DIR}/cmark/src/cmark_export.h
foreach(fn ${cmark_headers}) ${CMAKE_CURRENT_BINARY_DIR}/cmark/src/cmark_version.h)
get_filename_component(fn_name "${fn}" NAME) foreach(fn ${cmark_headers})
add_custom_command( get_filename_component(fn_name "${fn}" NAME)
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cmark/${fn_name} add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy ${fn} ${CMAKE_CURRENT_BINARY_DIR}/cmark/${fn_name} OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cmark/${fn_name}
MAIN_DEPENDENCY ${fn}) COMMAND ${CMAKE_COMMAND} -E copy ${fn} ${CMAKE_CURRENT_BINARY_DIR}/cmark/${fn_name}
list(APPEND copy_cmark_headers ${CMAKE_CURRENT_BINARY_DIR}/cmark/${fn_name}) MAIN_DEPENDENCY ${fn})
endforeach() list(APPEND copy_cmark_headers ${CMAKE_CURRENT_BINARY_DIR}/cmark/${fn_name})
add_custom_target(copy_cmark_headers DEPENDS ${copy_cmark_headers}) endforeach()
add_dependencies(libcmark_static copy_cmark_headers) add_custom_target(copy_cmark_headers DEPENDS ${copy_cmark_headers})
add_dependencies(libcmark_static copy_cmark_headers)
endif()