vcpkg/ports/graphqlparser/win-cmake.patch

105 lines
3.1 KiB
Diff
Raw Normal View History

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c4c8b3e..f19cda3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,16 +3,37 @@ PROJECT(libgraphqlparser C CXX)
SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
-INCLUDE(version)
+IF(UNIX)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
+ SET(FLEX_COMPILE_FLAGS "--header-file=lexer.h")
+ELSEIF(WIN32)
+ # If we're building this with vcpkg on Windows, let portfile.cmake tell us where it
+ # stored these tools. Otherwise these variables should be empty and we'll fall back
+ # to the normal CMake FIND_PACKAGE logic for each of these programs.
+ SET(CMAKE_PROGRAM_PATH
+ "${VCPKG_DOWNLOADS_PYTHON2_DIR}"
+ "${VCPKG_DOWNLOADS_FLEX_DIR}"
+ "${VCPKG_DOWNLOADS_BISON_DIR}"
+ "${CMAKE_PROGRAM_PATH}")
+
+ SET(FLEX_COMPILE_FLAGS "--header-file=lexer.h --wincompat")
+
+ # Let CMake figure out the exports for the SHARED library (DLL) on Windows.
+ SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
+ENDIF()
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
+INCLUDE(version)
FIND_PACKAGE(PythonInterp 2 REQUIRED)
IF (NOT PYTHON_VERSION_MAJOR EQUAL 2)
MESSAGE(FATAL_ERROR "Python 2 is required.")
ENDIF()
-FIND_PROGRAM(CTYPESGEN_FOUND ctypesgen.py)
+IF(UNIX)
+ SET(FLEX_COMPILE_FLAGS "--header-file=lexer.h")
+ELSEIF(WIN32)
+ SET(FLEX_COMPILE_FLAGS "--header-file=lexer.h --wincompat")
+ENDIF()
FIND_PACKAGE(BISON 3)
FIND_PACKAGE(FLEX)
@@ -21,7 +42,7 @@ IF (BISON_FOUND)
ENDIF()
IF(FLEX_FOUND)
- FLEX_TARGET(GraphQLScanner lexer.lpp ${CMAKE_CURRENT_SOURCE_DIR}/lexer.cpp COMPILE_FLAGS "--header-file=lexer.h")
+ FLEX_TARGET(GraphQLScanner lexer.lpp ${CMAKE_CURRENT_SOURCE_DIR}/lexer.cpp COMPILE_FLAGS ${FLEX_COMPILE_FLAGS})
IF (BISON_FOUND)
ADD_FLEX_BISON_DEPENDENCY(GraphQLScanner graphqlparser)
ENDIF()
@@ -83,11 +104,8 @@ GENERATE_AST_FILE(cxx_json_visitor_header JsonVisitor.h.inc)
GENERATE_AST_FILE(cxx_json_visitor_impl JsonVisitor.cpp.inc)
-ADD_SUBDIRECTORY(python)
-
-OPTION(test "Build tests." OFF)
-
INSTALL(DIRECTORY c ${CMAKE_CURRENT_BINARY_DIR}/c DESTINATION include/graphqlparser
+ CONFIGURATIONS Release
FILES_MATCHING PATTERN "*.h"
PATTERN "build" EXCLUDE)
@@ -103,9 +121,12 @@ INSTALL(FILES
position.hh
stack.hh
syntaxdefs.h
- DESTINATION include/graphqlparser)
+ DESTINATION include/graphqlparser
+ CONFIGURATIONS Release)
+
INSTALL(TARGETS graphqlparser
- LIBRARY DESTINATION lib)
+ LIBRARY DESTINATION lib
+ RUNTIME DESTINATION bin)
if (UNIX)
# generate pkgconfig file
@@ -116,16 +137,9 @@ if (UNIX)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libgraphqlparser.pc"
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
endif()
+elseif(WIN32)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/graphqlparser.lib
+ DESTINATION lib)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/graphqlparser.pdb
+ DESTINATION bin)
endif()
-
-IF (test)
- ADD_SUBDIRECTORY(test)
-
- if(UNIX)
- # setup valgrind
- ADD_CUSTOM_TARGET(memcheck
- valgrind --leak-check=full --suppressions=./test/valgrind.supp --dsymutil=yes --error-exitcode=1 ./test/runTests >/dev/null
- )
- endif()
-
-ENDIF()