mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-03-16 20:43:46 +00:00
Windows: Build updates
- Generate rc files from version.rc.in + CMake variable information in CMakeLists files - Add step to generate .lib file for windows developers - Re-structure tool flag usage, apparently ADD_DEFINTIONS adds them to _ALL_ tools. This is bad for rc files with the windres tool. Needs other platform testing, as the flags have changed to fix Windows rc file generation.
This commit is contained in:
@@ -29,7 +29,12 @@ SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
|
||||
# Options
|
||||
SET(LIBNFC_DEBUG_OUTPUT OFF CACHE BOOL "Debug output of communication with the NFC chip")
|
||||
IF(LIBNFC_DEBUG_OUTPUT)
|
||||
ADD_DEFINITIONS(-DDEBUG -DLOG -g3)
|
||||
ADD_DEFINITIONS(-DDEBUG -DLOG)
|
||||
SET(CMAKE_C_FLAGS "-g3 ${CMAKE_C_FLAGS}")
|
||||
SET(WIN32_MODE "debug")
|
||||
SET(CMAKE_RC_FLAGS "-D_DEBUG ${CMAKE_RC_FLAGS}")
|
||||
ELSE(LIBNFC_DEBUG_OUTPUT)
|
||||
SET(WIN32_MODE "release")
|
||||
ENDIF(LIBNFC_DEBUG_OUTPUT)
|
||||
|
||||
# Doxygen
|
||||
@@ -58,7 +63,7 @@ ENDIF(NOT DEFINED SHARE_INSTALL_PREFIX)
|
||||
# Additonnal GCC flags
|
||||
IF(CMAKE_COMPILER_IS_GNUCC)
|
||||
# Make sure we will not miss some warnings ;)
|
||||
ADD_DEFINITIONS(-Wall -pedantic -std=c99)
|
||||
SET(CMAKE_C_FLAGS "-Wall -pedantic -std=c99 ${CMAKE_C_FLAGS}")
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
||||
|
||||
# Workarounds for libusb in C99
|
||||
@@ -66,9 +71,11 @@ ADD_DEFINITIONS(-Du_int8_t=uint8_t -Du_int16_t=uint16_t)
|
||||
|
||||
IF(MINGW)
|
||||
# force MinGW-w64 in 32bit mode
|
||||
ADD_DEFINITIONS(-m32)
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS -m32)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS -m32)
|
||||
SET(CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}")
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS "-m32 --enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "-m32 --enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "-m32 --enable-stdcall-fixup ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
SET(CMAKE_RC_FLAGS "--target=pe-i386 --output-format=coff ${CMAKE_RC_FLAGS}")
|
||||
ENDIF(MINGW)
|
||||
|
||||
IF(NOT WIN32)
|
||||
@@ -107,6 +114,23 @@ IF(LIBUSB_INCLUDE_DIRS)
|
||||
LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS})
|
||||
ENDIF(LIBUSB_INCLUDE_DIRS)
|
||||
|
||||
# version.rc for Windows
|
||||
IF(WIN32)
|
||||
# Date for filling in rc file information
|
||||
MACRO (GET_CURRENT_YEAR RESULT)
|
||||
EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
|
||||
STRING(REGEX REPLACE ".*(..)/(..)/(....).*" "\\3" ${RESULT} ${${RESULT}})
|
||||
ENDMACRO (GET_CURRENT_YEAR)
|
||||
GET_CURRENT_YEAR(CURRENT_YEAR)
|
||||
MESSAGE("Year for copyright is " ${CURRENT_YEAR})
|
||||
|
||||
SET(RC_COMMENT "${PACKAGE_NAME} library")
|
||||
SET(RC_INTERNAL_NAME "${PACKAGE_NAME} ${WIN32_MODE}")
|
||||
SET(RC_ORIGINAL_NAME ${PACKAGE_NAME}.dll)
|
||||
SET(RC_FILE_TYPE VFT_DLL)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/windows/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/windows/libnfc.rc @ONLY)
|
||||
ENDIF(WIN32)
|
||||
|
||||
ADD_SUBDIRECTORY(libnfc)
|
||||
ADD_SUBDIRECTORY(include)
|
||||
ADD_SUBDIRECTORY(utils)
|
||||
|
||||
Reference in New Issue
Block a user