diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 6947016..558a2c1 100755 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -20,8 +20,9 @@ if(NOT COMMAND add_compile_options) endfunction() endif() -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") include(CheckCXXCompilerFlag) +include(ParserAndScanner) # ssam expects the libs to be in Debug/ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Debug) @@ -312,40 +313,16 @@ else() include_directories(External/libvorbis/include) endif() -# We build ECC, then use it to generate C++ code for the game entities... -macro(add_parser_and_scanner _PARSER _SCANNER) - add_custom_command( - OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_SCANNER}.cpp" - MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_SCANNER}.l" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - COMMAND flex - ARGS -o${_SCANNER}.cpp ${_SCANNER}.l - ) - - add_custom_command( - OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.hpp" - MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.y" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - COMMAND bison - ARGS -o${_PARSER}.cpp ${_PARSER}.y -d - ) - - add_custom_command( - OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.h" - MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.hpp" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - COMMAND ${CMAKE_COMMAND} - ARGS -E copy ${_PARSER}.hpp ${_PARSER}.h - ) -endmacro() - # Build ECC from source if there wasn't a prebuilt-one specified on the command line. # Normally we build it here, but we might need a prebuilt, native binary if # we're cross-compiling the rest of the game. -if(NOT ECC) - add_parser_and_scanner("Ecc/Parser" "Ecc/Scanner") - add_executable(ecc Ecc/Main.cpp Ecc/Parser.cpp Ecc/Parser.h Ecc/Scanner.cpp) - set(ECC "ecc") +if(ECC) + # Use given ecc. +elseif(CMAKE_CROSSCOMPILING) + message(FATAL_ERROR "ECC variable must point to native ecc binary when cross-compiling.") +else() + add_subdirectory(Ecc) + set(ECC ecc) endif() macro(entity _NAME) diff --git a/Sources/Ecc/CMakeLists.txt b/Sources/Ecc/CMakeLists.txt new file mode 100644 index 0000000..8113cf6 --- /dev/null +++ b/Sources/Ecc/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 2.8.7) +project(Ecc) + +if(MSVC) + add_compile_options(/W4) +else() + add_compile_options(-Wall) +endif() + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake") +include(ParserAndScanner) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_parser_and_scanner("Parser" "Scanner") +add_executable(ecc Main.cpp Parser.cpp Parser.h Scanner.cpp) diff --git a/Sources/Ecc/Main.cpp b/Sources/Ecc/Main.cpp index 558ae58..b5ab5c2 100644 --- a/Sources/Ecc/Main.cpp +++ b/Sources/Ecc/Main.cpp @@ -178,7 +178,6 @@ void ReplaceFileRL(const char *strOld, const char *strNew) // process each charachter for(int ich=0;ich #include -#ifdef PLATFORM_WIN32 +#ifdef _WIN32 #include -#endif - -#ifdef PLATFORM_UNIX +#else #include #include #include diff --git a/Sources/Ecc/unistd.h b/Sources/Ecc/unistd.h deleted file mode 100644 index c9c1cb0..0000000 --- a/Sources/Ecc/unistd.h +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (c) 2002-2012 Croteam Ltd. -This program is free software; you can redistribute it and/or modify -it under the terms of version 2 of the GNU General Public License as published by -the Free Software Foundation - - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -#include diff --git a/Sources/cmake/ParserAndScanner.cmake b/Sources/cmake/ParserAndScanner.cmake new file mode 100644 index 0000000..a2051ed --- /dev/null +++ b/Sources/cmake/ParserAndScanner.cmake @@ -0,0 +1,25 @@ +macro(add_parser_and_scanner _PARSER _SCANNER) + add_custom_command( + OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_SCANNER}.cpp" + MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_SCANNER}.l" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMAND flex + ARGS -o${_SCANNER}.cpp ${_SCANNER}.l + ) + + add_custom_command( + OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.hpp" + MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.y" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMAND bison + ARGS -o${_PARSER}.cpp ${_PARSER}.y -d + ) + + add_custom_command( + OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.h" + MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${_PARSER}.hpp" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${_PARSER}.hpp ${_PARSER}.h + ) +endmacro()