Skip to content

Commit

Permalink
CMake support
Browse files Browse the repository at this point in the history
  • Loading branch information
lexxmark committed Jan 23, 2018
1 parent 39d01b5 commit b28ac46
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*.userosscache
*.sln.docstates

# CMake folders
CMakeBuild*/

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

Expand Down
33 changes: 33 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)

project (winflexbison)

if(NOT MSVC)
message( FATAL_ERROR "Visual Studio Build supported only" )
endif()

# Output Variables
set(OUTPUT_DEBUG "${CMAKE_CURRENT_LIST_DIR}/bin/Debug")
set(OUTPUT_RELEASE "${CMAKE_CURRENT_LIST_DIR}/bin/Release")

add_definitions(-D_CRT_SECURE_NO_WARNINGS)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DEBUG}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_RELEASE}")

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-D_DEBUG)
endif()

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W3 /MD /Od /Zi /EHsc")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /GL /Od /Oi /Gy /Zi /EHsc")

# Define Release by default.
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
message(STATUS "Build type not specified: Use Release by default.")
endif()

add_subdirectory(common)
add_subdirectory(flex)
add_subdirectory(bison)
22 changes: 22 additions & 0 deletions bison/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)

set(PROJECT_NAME win_bison)

project(${PROJECT_NAME} C)

# Definition of Macros
add_definitions(-D_CONSOLE)

file(GLOB SOURCE_FILES
"src/*.c"
"src/*.h"
)

# Add executable to build.
add_executable(${PROJECT_NAME}
${SOURCE_FILES}
)

target_include_directories(${PROJECT_NAME} PRIVATE "src")

target_link_libraries(${PROJECT_NAME} common_lib kernel32.lib user32.lib)
4 changes: 4 additions & 0 deletions buildVS2015.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mkdir CMakeBuildVS2015
cd CMakeBuildVS2015
cmake .. -G "Visual Studio 14 2015"
cd ..
4 changes: 4 additions & 0 deletions buildVS2017.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mkdir CMakeBuildVS2017
cd CMakeBuildVS2017
cmake .. -G "Visual Studio 15 2017"
cd ..
30 changes: 30 additions & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)

set(PROJECT_NAME common_lib)

project(${PROJECT_NAME} C)

# Definition of Macros
add_definitions(-D_LIB)

file(GLOB SOURCE_FILES
"misc/*.c"
"misc/*.h"
"m4/*.c"
"m4/*.h"
"m4/lib/*.c"
"m4/lib/*.h"
)
# exclude some source files
list(REMOVE_ITEM SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/m4/lib/regexec.c")
list(REMOVE_ITEM SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/m4/lib/regcomp.c")

# Add library to build.
add_library(${PROJECT_NAME} STATIC
${SOURCE_FILES}
)

target_include_directories(${PROJECT_NAME} PUBLIC "misc")
target_include_directories(${PROJECT_NAME} PUBLIC "m4")
target_include_directories(${PROJECT_NAME} PUBLIC "m4/lib")

25 changes: 25 additions & 0 deletions flex/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)

set(PROJECT_NAME win_flex)

project(${PROJECT_NAME} C)

# Definition of Macros
add_definitions(-D_CONSOLE)

file(GLOB SOURCE_FILES
"src/*.c"
"src/*.h"
)
# exclude some source files
list(REMOVE_ITEM SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/libmain.c")
list(REMOVE_ITEM SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/libyywrap.c")

# Add executable to build.
add_executable(${PROJECT_NAME}
${SOURCE_FILES}
)

target_include_directories(${PROJECT_NAME} PRIVATE "src")

target_link_libraries(${PROJECT_NAME} common_lib kernel32.lib user32.lib)

0 comments on commit b28ac46

Please sign in to comment.