Merge pull request #12 from M1cha/master

added CMake build system
This commit is contained in:
albertodemichelis 2016-02-04 00:57:04 +08:00
commit 20f6f78c8d
4 changed files with 105 additions and 0 deletions

39
CMakeLists.txt Normal file
View File

@ -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)

22
sq/CMakeLists.txt Normal file
View File

@ -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})

20
sqstdlib/CMakeLists.txt Normal file
View File

@ -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})

24
squirrel/CMakeLists.txt Normal file
View File

@ -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})