From 05686755611dc069ad8107a6793189fd9bdf4234 Mon Sep 17 00:00:00 2001 From: M1cha Date: Fri, 29 Jan 2016 18:56:44 +0100 Subject: [PATCH] switch to CMake build system --- CMakeLists.txt | 39 +++++++++++++++++++++++++++++++++++++++ sq/CMakeLists.txt | 22 ++++++++++++++++++++++ sqstdlib/CMakeLists.txt | 20 ++++++++++++++++++++ squirrel/CMakeLists.txt | 24 ++++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 sq/CMakeLists.txt create mode 100644 sqstdlib/CMakeLists.txt create mode 100644 squirrel/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..29be748 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 2.8) +project(squirrel) + +# get machine +execute_process( COMMAND ${CMAKE_C_COMPILER} -dumpmachine OUTPUT_VARIABLE DUMP_MACHINE OUTPUT_STRIP_TRAILING_WHITESPACE) +message("Dump Machine : ${DUMP_MACHINE}") + +# get architecture +if(NOT DEFINED ARCHITECTURE) + string(FIND ${DUMP_MACHINE} "-" DUMP_MACHINE_STRIP) + string(SUBSTRING ${DUMP_MACHINE} 0 ${DUMP_MACHINE_STRIP} ARCHITECTURE) +endif() +message("Architecture : ${ARCHITECTURE}") + +# global includes +include_directories( + ${PROJECT_SOURCE_DIR}/include +) + +# global flags +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti -Wall -fno-strict-aliasing") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions -Wall -fno-strict-aliasing") + +set(SQGLOB_FLAGS_RELEASE "-O2") +set(SQGLOB_FLAGS_DEBUG "-pg -pie -gstabs -g3") +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${SQGLOB_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_DEBUG} ${SQGLOB_FLAGS_DEBUG}") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${SQGLOB_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} ${SQGLOB_FLAGS_DEBUG}") + +if("${ARCHITECTURE}" STREQUAL "x86_64") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SQ64") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_SQ64") +endif() + +# subdirectories +add_subdirectory(squirrel) +add_subdirectory(sqstdlib) +add_subdirectory(sq) diff --git a/sq/CMakeLists.txt b/sq/CMakeLists.txt new file mode 100644 index 0000000..19a4ac7 --- /dev/null +++ b/sq/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 2.8) +project(libsquirrel) + +# sources +set(SQ_SRCS + sq.c +) + +# libs +set(SQ_LIBS + sqstd + squirrel +) + +# shared lib +add_executable(sq ${SQ_SRCS}) +target_link_libraries(sq ${SQ_LIBS}) + +# static lib +add_executable(sq_static ${SQ_SRCS}) +set_target_properties(sq_static PROPERTIES COMPILE_FLAGS "-static -Wl,-static") +target_link_libraries(sq_static ${SQ_LIBS}) diff --git a/sqstdlib/CMakeLists.txt b/sqstdlib/CMakeLists.txt new file mode 100644 index 0000000..6cc209d --- /dev/null +++ b/sqstdlib/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 2.8) +project(sqstd) + +# sources +set(SQSTD_SRCS + sqstdblob.cpp + sqstdio.cpp + sqstdstream.cpp + sqstdmath.cpp + sqstdsystem.cpp + sqstdstring.cpp + sqstdaux.cpp + sqstdrex.cpp +) + +# shared lib +add_library(sqstd SHARED ${SQSTD_SRCS}) + +# static lib +add_library(sqstd_static STATIC ${SQSTD_SRCS}) diff --git a/squirrel/CMakeLists.txt b/squirrel/CMakeLists.txt new file mode 100644 index 0000000..e46e9a5 --- /dev/null +++ b/squirrel/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 2.8) +project(libsquirrel) + +# sources +set(SQUIRREL_SRCS + sqapi.cpp + sqbaselib.cpp + sqfuncstate.cpp + sqdebug.cpp + sqlexer.cpp + sqobject.cpp + sqcompiler.cpp + sqstate.cpp + sqtable.cpp + sqmem.cpp + sqvm.cpp + sqclass.cpp +) + +# shared lib +add_library(squirrel SHARED ${SQUIRREL_SRCS}) + +# static lib +add_library(squirrel_static STATIC ${SQUIRREL_SRCS})