Updated CMakeLists to fix iowin32.c with MSVC

This commit is contained in:
Alex Huszagh 2017-07-10 14:03:08 -07:00
parent 2f06734178
commit de4afb49f5

View File

@ -60,11 +60,13 @@
# https://cmake.org/cmake/help/v3.0/manual/cmake-generators.7.html # https://cmake.org/cmake/help/v3.0/manual/cmake-generators.7.html
# #
set(CMAKE_LEGACY_CYGWIN_WIN32 1)
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
SET(PROJECT_NAME "xlsxwriter" CACHE STRING "Optional project and binary name") SET(PROJECT_NAME "xlsxwriter" CACHE STRING "Optional project and binary name")
project(${PROJECT_NAME} C) project(${PROJECT_NAME} C)
enable_testing()
# OPTIONS # OPTIONS
# ------- # -------
@ -75,10 +77,15 @@ option(BUILD_STATIC "Build static libxlsxwriter" ON)
option(BUILD_TESTS "Build libxlsxwriter tests" OFF) option(BUILD_TESTS "Build libxlsxwriter tests" OFF)
option(BUILD_EXAMPLES "Build libxlsxwriter examples" OFF) option(BUILD_EXAMPLES "Build libxlsxwriter examples" OFF)
option(USE_STANDARD_TMPFILE "Use the C standard library's tmpfile()" OFF) option(USE_STANDARD_TMPFILE "Use the C standard library's tmpfile()" OFF)
option(IOAPI_NO_64 "Disable 64-bit filesystem support" OFF)
if(DEFINED ENV{${ZLIB_ROOT}}) if(DEFINED ENV{${ZLIB_ROOT}})
set(ZLIB_ROOT $ENV{ZLIB_ROOT}) set(ZLIB_ROOT $ENV{ZLIB_ROOT})
endif() endif()
if(IOAPI_NO_64)
add_definitions(-DIOAPI_NO_64=1)
endif()
# CONFIGURATIONS # CONFIGURATIONS
# -------------- # --------------
@ -89,7 +96,7 @@ endif()
if(BUILD_STATIC) if(BUILD_STATIC)
if(UNIX) if(UNIX)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
elseif(${MINGW} OR ${MSYS}) elseif(MINGW OR MSYS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -static-libgcc -Wno-char-subscripts -Wno-long-long") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -static-libgcc -Wno-char-subscripts -Wno-long-long")
add_definitions(-DUSE_FILE32API) add_definitions(-DUSE_FILE32API)
elseif(MSVC) elseif(MSVC)
@ -114,6 +121,9 @@ add_definitions(-DNOCRYPT -DNOUNCRYPT)
include_directories(include include/xlsxwriter) include_directories(include include/xlsxwriter)
file(GLOB LXW_SOURCES src/*.c) file(GLOB LXW_SOURCES src/*.c)
list(APPEND LXW_SOURCES third_party/minizip/ioapi.c third_party/minizip/zip.c) list(APPEND LXW_SOURCES third_party/minizip/ioapi.c third_party/minizip/zip.c)
if(MSVC)
list(APPEND LXW_SOURCES third_party/minizip/iowin32.c)
endif()
if (NOT ${USE_STANDARD_TMPFILE}) if (NOT ${USE_STANDARD_TMPFILE})
include_directories(third_party/tmpfileplus) include_directories(third_party/tmpfileplus)
list(APPEND LXW_SOURCES third_party/tmpfileplus/tmpfileplus.c) list(APPEND LXW_SOURCES third_party/tmpfileplus/tmpfileplus.c)
@ -151,9 +161,9 @@ macro(CreateTest sources target)
add_executable(${output_name} ${${sources}}) add_executable(${output_name} ${${sources}})
target_link_libraries(${output_name} ${PROJECT_NAME} ${ZLIB_LIBRARIES}) target_link_libraries(${output_name} ${PROJECT_NAME} ${ZLIB_LIBRARIES})
add_custom_target(check_${output_name} add_test(NAME ${output_name}
COMMAND $<TARGET_FILE:${output_name}> COMMAND ${output_name}
DEPENDS ${dependencies} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
) )
endmacro(CreateTest) endmacro(CreateTest)
@ -241,7 +251,7 @@ if(MSVC)
install(FILES $<TARGET_FILE_DIR:${PROJECT_NAME}>/${PROJECT_NAME}.pdb install(FILES $<TARGET_FILE_DIR:${PROJECT_NAME}>/${PROJECT_NAME}.pdb
DESTINATION "lib/Win32/\${CMAKE_INSTALL_CONFIG_NAME}" DESTINATION "lib/Win32/\${CMAKE_INSTALL_CONFIG_NAME}"
) )
endif() endif()
else(MSVC) else(MSVC)
install(TARGETS ${PROJECT_NAME} install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib LIBRARY DESTINATION lib