Skip to content

Commit 3f643fc

Browse files
committed
Fixing Cmake Windows support
* Referencing graphql#35
1 parent 86550f2 commit 3f643fc

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

CMakeLists.txt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ INCLUDE(version)
77

88
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
99

10+
IF(WIN32)
11+
ADD_DEFINITIONS(-DYY_NO_UNISTD_H)
12+
ENDIF()
13+
1014
FIND_PACKAGE(PythonInterp 2 REQUIRED)
1115
IF (NOT PYTHON_VERSION_MAJOR EQUAL 2)
1216
MESSAGE(FATAL_ERROR "Python 2 is required.")
@@ -31,7 +35,7 @@ FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/c)
3135
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
3236
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
3337

34-
ADD_LIBRARY(graphqlparser SHARED
38+
ADD_LIBRARY(graphqlparser STATIC
3539
JsonVisitor.cpp
3640
${CMAKE_CURRENT_BINARY_DIR}/Ast.h
3741
${CMAKE_CURRENT_BINARY_DIR}/Ast.cpp
@@ -104,8 +108,17 @@ INSTALL(FILES
104108
stack.hh
105109
syntaxdefs.h
106110
DESTINATION include/graphqlparser)
107-
INSTALL(TARGETS graphqlparser
108-
LIBRARY DESTINATION lib)
111+
112+
# Common Cmake MSVC TARGET workaround https://stackoverflow.com/a/37729574
113+
if(WIN32)
114+
install(TARGETS graphqlparser
115+
ARCHIVE DESTINATION lib
116+
RUNTIME DESTINATION lib)
117+
else()
118+
INSTALL(TARGETS graphqlparser
119+
LIBRARY DESTINATION lib)
120+
endif()
121+
109122

110123
if (UNIX)
111124
# generate pkgconfig file

lexer.lpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static void escape(char c, char *buf);
2626

2727
%option bison-bridge bison-locations
2828
%option noyywrap batch noinput nounput
29+
%option never-interactive
2930
%option reentrant
3031
%option extra-type="struct LexerExtra *"
3132

0 commit comments

Comments
 (0)