vcpkg/ports/libmupdf/CMakeLists.txt
simon987 c0d6fc23c1
[libmupdf] fix build error on Linux (#10708)
* minimum to compile on linux

* Update as reviewed

* Update baseline and add the condition to execuate script

* Move find_program and make it REQUIRED

* always execute generate command

* only use make in find_program

Co-authored-by: Nancy Li (Beyondsoft Corporation) <v-ruil@microsoft.com>
2020-04-24 02:58:24 -07:00

66 lines
1.7 KiB
CMake

cmake_minimum_required(VERSION 3.9)
project(libmupdf C)
set(CMAKE_DEBUG_POSTFIX d)
if(WIN32)
execute_process(
COMMAND "cmd.exe" "/c" "platform\\win32\\generate.bat"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
else()
find_program(MAKE_EXE NAMES make REQUIRED)
execute_process(
COMMAND ${MAKE_EXE} "generate"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
endif()
find_package(freetype NO_MODULE REQUIRED)
find_package(JPEG REQUIRED)
find_path(HARFBUZZ_INCLUDE hb.h PATH_SUFFIXES harfbuzz)
find_library(HARFBUZZ_LIBRARIES harfbuzz)
find_package(ZLIB REQUIRED)
find_package(OpenJPEG CONFIG REQUIRED)
find_library(JBIG2DEC_LIB NAMES jbig2decd jbig2dec)
file(GLOB_RECURSE SOURCES "source/*.c" "generated/*.c")
list(FILTER SOURCES EXCLUDE REGEX "source/tools/[a-z]*\\.c$")
list(FILTER SOURCES EXCLUDE REGEX "source/tests/.*.c$")
add_library(libmupdf ${SOURCES})
if(WIN32)
target_compile_definitions(libmupdf PRIVATE -DSHARE_JPEG -DFZ_ENABLE_JS=0 -DFZ_ENABLE_ICC=0)
else()
target_compile_definitions(libmupdf PRIVATE -DSHARE_JPEG -DFZ_ENABLE_JS=0 -DFZ_ENABLE_ICC=0 -DHAVE_PTHREAD=1)
endif()
target_include_directories(libmupdf
PUBLIC
include
PRIVATE
generated
${JPEG_INCLUDE_DIR}
${HARFBUZZ_INCLUDE}
)
target_link_libraries(libmupdf PRIVATE
openjp2
freetype
${JPEG_LIBRARIES}
${HARFBUZZ_LIBRARIES}
${JBIG2DEC_LIB}
ZLIB::ZLIB
)
install(TARGETS libmupdf
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
if(BUILD_EXAMPLES)
add_executable(mu-office-test source/tests/mu-office-test.c)
target_link_libraries(mu-office-test PRIVATE libmupdf)
endif()