mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-11-22 10:20:26 +01:00
Allow ecc to be built independently using its own CMakeLists.txt file
This makes cross-compiling easier, and saves having to build once each for TFE and TSE. I considered using CMake's import/export feature, but there's little point when you're only importing one binary target. Pointing the ECC variable at the ecc binary itself is simpler. I copied the minimum CMake version of 2.8.7 from the parent project. To be confident this would actually work, I tested building under CentOS 7 with CMake 2.8.12.
This commit is contained in:
parent
bd68934e32
commit
c09d18623e
|
@ -20,8 +20,9 @@ if(NOT COMMAND add_compile_options)
|
||||||
endfunction()
|
endfunction()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
include(ParserAndScanner)
|
||||||
|
|
||||||
# ssam expects the libs to be in Debug/
|
# ssam expects the libs to be in Debug/
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Debug)
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Debug)
|
||||||
|
@ -312,40 +313,16 @@ else()
|
||||||
include_directories(External/libvorbis/include)
|
include_directories(External/libvorbis/include)
|
||||||
endif()
|
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.
|
# 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
|
# Normally we build it here, but we might need a prebuilt, native binary if
|
||||||
# we're cross-compiling the rest of the game.
|
# we're cross-compiling the rest of the game.
|
||||||
if(NOT ECC)
|
if(ECC)
|
||||||
add_parser_and_scanner("Ecc/Parser" "Ecc/Scanner")
|
# Use given ecc.
|
||||||
add_executable(ecc Ecc/Main.cpp Ecc/Parser.cpp Ecc/Parser.h Ecc/Scanner.cpp)
|
elseif(CMAKE_CROSSCOMPILING)
|
||||||
set(ECC "ecc")
|
message(FATAL_ERROR "ECC variable must point to native ecc binary when cross-compiling.")
|
||||||
|
else()
|
||||||
|
add_subdirectory(Ecc)
|
||||||
|
set(ECC ecc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
macro(entity _NAME)
|
macro(entity _NAME)
|
||||||
|
|
18
Sources/Ecc/CMakeLists.txt
Normal file
18
Sources/Ecc/CMakeLists.txt
Normal file
|
@ -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)
|
|
@ -1,7 +1,7 @@
|
||||||
%{
|
%{
|
||||||
// rcg10042001 Changed to specify Ecc directory...
|
// rcg10042001 Changed to specify Ecc directory...
|
||||||
#include "Ecc/StdH.h"
|
#include "StdH.h"
|
||||||
#include "Ecc/Main.h"
|
#include "Main.h"
|
||||||
|
|
||||||
// turn off over-helpful bit of bison... --ryan.
|
// turn off over-helpful bit of bison... --ryan.
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
%{
|
%{
|
||||||
// rcg10042001 Changed to specify Ecc directory...
|
#include "StdH.h"
|
||||||
#include "Ecc/StdH.h"
|
#include "Main.h"
|
||||||
#include "Ecc/Main.h"
|
#include "Parser.h"
|
||||||
#include "Ecc/Parser.h"
|
|
||||||
|
|
||||||
#define YY_NEVER_INTERACTIVE 1
|
#define YY_NEVER_INTERACTIVE 1
|
||||||
|
|
||||||
|
|
25
Sources/cmake/ParserAndScanner.cmake
Normal file
25
Sources/cmake/ParserAndScanner.cmake
Normal file
|
@ -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()
|
Loading…
Reference in New Issue
Block a user