From 2fb3522470b46b2d0016986e3361f4231daab1c3 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Sun, 6 Mar 2016 19:43:57 +0100 Subject: [PATCH 1/8] Various improvements --- CMakeLists.txt | 71 +++++++++++++++++++++------------------- COMPILE | 23 +++++++++++++ README | 23 +++++++++---- include/squirrel.h | 6 ++++ sq/CMakeLists.txt | 30 +++++++---------- sq/sq.c | 8 ++--- sqstdlib/CMakeLists.txt | 31 ++++++++---------- sqstdlib/sqstdblob.cpp | 4 +-- sqstdlib/sqstdio.cpp | 4 +-- sqstdlib/sqstdmath.cpp | 2 +- sqstdlib/sqstdstream.cpp | 2 +- sqstdlib/sqstdstring.cpp | 6 ++-- sqstdlib/sqstdsystem.cpp | 2 +- squirrel/CMakeLists.txt | 38 +++++++++------------ squirrel/sqapi.cpp | 2 +- squirrel/sqbaselib.cpp | 26 +++++++-------- squirrel/sqclass.cpp | 2 +- squirrel/sqcompiler.cpp | 1 + squirrel/sqmem.cpp | 4 +-- squirrel/sqstate.cpp | 2 +- squirrel/sqvm.cpp | 4 +-- 21 files changed, 155 insertions(+), 136 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29be748..4f58a17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,39 +1,42 @@ -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") +if(MSVC) + cmake_minimum_required(VERSION 3.4) +else() + cmake_minimum_required(VERSION 2.8) +endif() + +set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}" CACHE PATH "") +set(CMAKE_BUILD_TYPE "Release" CACHE STRING "") + +project(squirrel C CXX) + +include_directories(${CMAKE_SOURCE_DIR}/include) + +if(CMAKE_COMPILER_IS_GNUCXX) + set(SQ_FLAGS -fno-exceptions -fno-strict-aliasing -Wall -Wextra) + + if(CMAKE_BUILD_TYPE STREQUAL "Release") + set(SQ_FLAGS ${SQ_FLAGS} -O3) + else() + set(SQ_FLAGS ${SQ_FLAGS} -pg -pie -gstabs -g3) + endif() + + if(CMAKE_VERSION VERSION_GREATER 3) + add_compile_options(${SQ_FLAGS}) + else() + add_definitions(${SQ_FLAGS}) + endif() + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") +elseif(MSVC) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +endif() + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + add_definitions(-D_SQ64) endif() -# subdirectories add_subdirectory(squirrel) add_subdirectory(sqstdlib) add_subdirectory(sq) + +install(FILES doc/squirrel3.pdf doc/sqstdlib3.pdf DESTINATION share/doc/squirrel3) diff --git a/COMPILE b/COMPILE index 9e92e52..05591a8 100644 --- a/COMPILE +++ b/COMPILE @@ -23,6 +23,29 @@ samples HOW TO COMPILE --------------------------------------------------------- +CMAKE USERS +......................................................... +If you want to build the shared libraries under Windows using Visual +Studio, you will have to use CMake version 3.4 or newer. If not, an +earlier version will suffice. For a traditional out-of-source build +under Linux, type something like + + $ mkdir build # Create temporary build directory + $ cd build + $ cmake .. # CMake will determine all the necessary information, + # including the platform (32- vs. 64-Bit) + $ make + $ make install + $ cd ..; rm -r build + +The default installation directory will be the top source directory, +i. e. the binaries will go into bin/ and the libraries into lib/. You +can change this behavior by calling CMake like this: + + $ cmake .. -DCMAKE_INSTALL_PREFIX=/some/path/on/your/system + +Under Windows, it is probably easiest to use the CMake GUI interface. + GCC USERS ......................................................... There is a very simple makefile that compiles all libraries and exes diff --git a/README b/README index 30a2199..af1a656 100644 --- a/README +++ b/README @@ -1,16 +1,26 @@ The programming language SQUIRREL 3.1 stable -------------------------------------------------- -The project has been compiled and run on Windows(x86 and x64) and -Linux(x86 and x64) and Solaris(x86 and x64). +This project has successfully been compiled and run on + * Windows (x86 and amd64) + * Linux (x86, amd64 and ARM) + * Solaris (x86 and amd64) -Has been tested with the following compilers: - MS Visual C++ 6.0,7.0,7.1,8.0,9.0,10.0 (32 and 64bits) +The following compilers have been confirmed to be working: + MS Visual C++ 6.0 (all on x86 and amd64) + 7.0 | + 7.1 v + 8.0 + 9.0 + 10.0 --- + 12.0 (only on x86) MinGW gcc 3.2 (mingw special 20020817-1) Cygnus gcc 3.2 Linux gcc 3.2.3 - Linux gcc 4.0.0 (x86 & 64bits) - Solaris gcc 4.0.0 (x86 & 64bits) + 4.0.0 (x86 and amd64) + 5.3.1 (amd64) + Solaris gcc 4.0.0 (x86 and amd64) + ARM Linux gcc 4.6.3 (Raspberry Pi Model B) Feedback and suggestions are appreciated @@ -20,4 +30,3 @@ wiki - http://wiki.squirrel-lang.org author - alberto@demichelis.net END OF README - diff --git a/include/squirrel.h b/include/squirrel.h index 408b609..33c7b05 100644 --- a/include/squirrel.h +++ b/include/squirrel.h @@ -392,6 +392,12 @@ SQUIRREL_API void sq_setnativedebughook(HSQUIRRELVM v,SQDEBUGHOOK hook); #define SQ_FAILED(res) (res<0) #define SQ_SUCCEEDED(res) (res>=0) +#ifdef __GNUC__ +# define SQ_UNUSED_ARG(x) __attribute__((unused)) x +#else +# define SQ_UNUSED_ARG(x) x +#endif + #ifdef __cplusplus } /*extern "C"*/ #endif diff --git a/sq/CMakeLists.txt b/sq/CMakeLists.txt index 19a4ac7..424ec9e 100644 --- a/sq/CMakeLists.txt +++ b/sq/CMakeLists.txt @@ -1,22 +1,14 @@ -cmake_minimum_required(VERSION 2.8) -project(libsquirrel) +add_executable(sq sq.c) +set_target_properties(sq PROPERTIES LINKER_LANGUAGE C) +target_link_libraries(sq squirrel sqstd) +install(TARGETS sq RUNTIME DESTINATION bin) -# sources -set(SQ_SRCS - sq.c -) +add_executable(sq_static sq.c) +set_target_properties(sq_static PROPERTIES LINKER_LANGUAGE C) +target_link_libraries(sq_static squirrel_static sqstd_static) -# libs -set(SQ_LIBS - sqstd - squirrel -) +if(CMAKE_COMPILER_IS_GNUCXX) + set_target_properties(sq_static PROPERTIES COMPILE_FLAGS "-static -Wl,-static") +endif() -# 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}) +install(TARGETS sq_static RUNTIME DESTINATION bin) diff --git a/sq/sq.c b/sq/sq.c index 0a96771..980903c 100644 --- a/sq/sq.c +++ b/sq/sq.c @@ -46,7 +46,7 @@ SQInteger quit(HSQUIRRELVM v) return 0; } -void printfunc(HSQUIRRELVM v,const SQChar *s,...) +void printfunc(HSQUIRRELVM SQ_UNUSED_ARG(v),const SQChar *s,...) { va_list vl; va_start(vl, s); @@ -54,7 +54,7 @@ void printfunc(HSQUIRRELVM v,const SQChar *s,...) va_end(vl); } -void errorfunc(HSQUIRRELVM v,const SQChar *s,...) +void errorfunc(HSQUIRRELVM SQ_UNUSED_ARG(v),const SQChar *s,...) { va_list vl; va_start(vl, s); @@ -87,10 +87,7 @@ int getargs(HSQUIRRELVM v,int argc, char* argv[],SQInteger *retval) { int i; int compiles_only = 0; - static SQChar temp[500]; - const SQChar *ret=NULL; char * output = NULL; - int lineinfo=0; *retval = 0; if(argc>1) { @@ -307,7 +304,6 @@ int main(int argc, char* argv[]) { HSQUIRRELVM v; SQInteger retval = 0; - const SQChar *filename=NULL; #if defined(_MSC_VER) && defined(_DEBUG) _CrtSetAllocHook(MemAllocHook); #endif diff --git a/sqstdlib/CMakeLists.txt b/sqstdlib/CMakeLists.txt index 1e940a1..0a8f15e 100644 --- a/sqstdlib/CMakeLists.txt +++ b/sqstdlib/CMakeLists.txt @@ -1,20 +1,15 @@ -cmake_minimum_required(VERSION 2.8) -project(sqstd) +set(SQSTD_SRC sqstdblob.cpp + sqstdio.cpp + sqstdstream.cpp + sqstdmath.cpp + sqstdsystem.cpp + sqstdstring.cpp + sqstdaux.cpp + sqstdrex.cpp) -# sources -set(SQSTD_SRCS - sqstdblob.cpp - sqstdio.cpp - sqstdstream.cpp - sqstdmath.cpp - sqstdsystem.cpp - sqstdstring.cpp - sqstdaux.cpp - sqstdrex.cpp -) +add_library(sqstd SHARED ${SQSTD_SRC}) +target_link_libraries(sqstd squirrel) +install(TARGETS sqstd LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) -# shared lib -add_library(sqstd SHARED ${SQSTD_SRCS}) - -# static lib -add_library(sqstd_static STATIC ${SQSTD_SRCS}) +add_library(sqstd_static STATIC ${SQSTD_SRC}) +install(TARGETS sqstd_static ARCHIVE DESTINATION lib) diff --git a/sqstdlib/sqstdblob.cpp b/sqstdlib/sqstdblob.cpp index e4c6690..590cde7 100644 --- a/sqstdlib/sqstdblob.cpp +++ b/sqstdlib/sqstdblob.cpp @@ -114,7 +114,7 @@ static SQInteger _blob__typeof(HSQUIRRELVM v) return 1; } -static SQInteger _blob_releasehook(SQUserPointer p, SQInteger size) +static SQInteger _blob_releasehook(SQUserPointer p, SQInteger SQ_UNUSED_ARG(size)) { SQBlob *self = (SQBlob*)p; self->~SQBlob(); @@ -230,7 +230,7 @@ static const SQRegFunction bloblib_funcs[]={ _DECL_GLOBALBLOB_FUNC(swap2,2,_SC(".n")), _DECL_GLOBALBLOB_FUNC(swap4,2,_SC(".n")), _DECL_GLOBALBLOB_FUNC(swapfloat,2,_SC(".n")), - {0,0} + {0,0,0,0} }; SQRESULT sqstd_getblob(HSQUIRRELVM v,SQInteger idx,SQUserPointer *ptr) diff --git a/sqstdlib/sqstdio.cpp b/sqstdlib/sqstdio.cpp index c648724..43277f1 100644 --- a/sqstdlib/sqstdio.cpp +++ b/sqstdlib/sqstdio.cpp @@ -115,7 +115,7 @@ static SQInteger _file__typeof(HSQUIRRELVM v) return 1; } -static SQInteger _file_releasehook(SQUserPointer p, SQInteger size) +static SQInteger _file_releasehook(SQUserPointer p, SQInteger SQ_UNUSED_ARG(size)) { SQFile *self = (SQFile*)p; self->~SQFile(); @@ -463,7 +463,7 @@ static const SQRegFunction iolib_funcs[]={ _DECL_GLOBALIO_FUNC(loadfile,-2,_SC(".sb")), _DECL_GLOBALIO_FUNC(dofile,-2,_SC(".sb")), _DECL_GLOBALIO_FUNC(writeclosuretofile,3,_SC(".sc")), - {0,0} + {0,0,0,0} }; SQRESULT sqstd_register_iolib(HSQUIRRELVM v) diff --git a/sqstdlib/sqstdmath.cpp b/sqstdlib/sqstdmath.cpp index 63f55f5..b29fdf8 100644 --- a/sqstdlib/sqstdmath.cpp +++ b/sqstdlib/sqstdmath.cpp @@ -78,7 +78,7 @@ static const SQRegFunction mathlib_funcs[] = { _DECL_FUNC(rand,1,NULL), _DECL_FUNC(fabs,2,_SC(".n")), _DECL_FUNC(abs,2,_SC(".n")), - {0,0}, + {0,0,0,0}, }; #undef _DECL_FUNC diff --git a/sqstdlib/sqstdstream.cpp b/sqstdlib/sqstdstream.cpp index a7081fa..ea1c58c 100644 --- a/sqstdlib/sqstdstream.cpp +++ b/sqstdlib/sqstdstream.cpp @@ -249,7 +249,7 @@ static const SQRegFunction _stream_methods[] = { _DECL_STREAM_FUNC(eos,1,_SC("x")), _DECL_STREAM_FUNC(flush,1,_SC("x")), _DECL_STREAM_FUNC(_cloned,0,NULL), - {0,0} + {0,0,0,0} }; void init_streamclass(HSQUIRRELVM v) diff --git a/sqstdlib/sqstdstring.cpp b/sqstdlib/sqstdstring.cpp index 1ce1149..9be7996 100644 --- a/sqstdlib/sqstdstring.cpp +++ b/sqstdlib/sqstdstring.cpp @@ -350,7 +350,7 @@ static SQInteger _string_endswith(HSQUIRRELVM v) SQRex *self = NULL; \ sq_getinstanceup(v,1,(SQUserPointer *)&self,0); -static SQInteger _rexobj_releasehook(SQUserPointer p, SQInteger size) +static SQInteger _rexobj_releasehook(SQUserPointer p, SQInteger SQ_UNUSED_ARG(size)) { SQRex *self = ((SQRex *)p); sqstd_rex_free(self); @@ -452,7 +452,7 @@ static const SQRegFunction rexobj_funcs[]={ _DECL_REX_FUNC(capture,-2,_SC("xsn")), _DECL_REX_FUNC(subexpcount,1,_SC("x")), _DECL_REX_FUNC(_typeof,1,_SC("x")), - {0,0} + {0,0,0,0} }; #undef _DECL_REX_FUNC @@ -466,7 +466,7 @@ static const SQRegFunction stringlib_funcs[]={ _DECL_FUNC(escape,2,_SC(".s")), _DECL_FUNC(startswith,3,_SC(".ss")), _DECL_FUNC(endswith,3,_SC(".ss")), - {0,0} + {0,0,0,0} }; #undef _DECL_FUNC diff --git a/sqstdlib/sqstdsystem.cpp b/sqstdlib/sqstdsystem.cpp index 959d631..5d46e27 100644 --- a/sqstdlib/sqstdsystem.cpp +++ b/sqstdlib/sqstdsystem.cpp @@ -126,7 +126,7 @@ static const SQRegFunction systemlib_funcs[]={ _DECL_FUNC(date,-1,_SC(".nn")), _DECL_FUNC(remove,2,_SC(".s")), _DECL_FUNC(rename,3,_SC(".ss")), - {0,0} + {0,0,0,0} }; #undef _DECL_FUNC diff --git a/squirrel/CMakeLists.txt b/squirrel/CMakeLists.txt index e46e9a5..d47ca15 100644 --- a/squirrel/CMakeLists.txt +++ b/squirrel/CMakeLists.txt @@ -1,24 +1,18 @@ -cmake_minimum_required(VERSION 2.8) -project(libsquirrel) +set(SQUIRREL_SRC sqapi.cpp + sqbaselib.cpp + sqfuncstate.cpp + sqdebug.cpp + sqlexer.cpp + sqobject.cpp + sqcompiler.cpp + sqstate.cpp + sqtable.cpp + sqmem.cpp + sqvm.cpp + sqclass.cpp) -# 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 -) +add_library(squirrel SHARED ${SQUIRREL_SRC}) +install(TARGETS squirrel LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) -# shared lib -add_library(squirrel SHARED ${SQUIRREL_SRCS}) - -# static lib -add_library(squirrel_static STATIC ${SQUIRREL_SRCS}) +add_library(squirrel_static STATIC ${SQUIRREL_SRC}) +install(TARGETS squirrel_static ARCHIVE DESTINATION lib) diff --git a/squirrel/sqapi.cpp b/squirrel/sqapi.cpp index 38505bd..56187b0 100644 --- a/squirrel/sqapi.cpp +++ b/squirrel/sqapi.cpp @@ -180,7 +180,7 @@ SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po) #endif } -SQUnsignedInteger sq_getvmrefcount(HSQUIRRELVM v, const HSQOBJECT *po) +SQUnsignedInteger sq_getvmrefcount(HSQUIRRELVM SQ_UNUSED_ARG(v), const HSQOBJECT *po) { if (!ISREFCOUNTED(type(*po))) return 0; return po->_unVal.pRefCounted->_uiRef; diff --git a/squirrel/sqbaselib.cpp b/squirrel/sqbaselib.cpp index 41efa53..ed3d4c1 100644 --- a/squirrel/sqbaselib.cpp +++ b/squirrel/sqbaselib.cpp @@ -40,7 +40,7 @@ static bool str2num(const SQChar *s,SQObjectPtr &res,SQInteger base) return true; } -static SQInteger base_dummy(HSQUIRRELVM v) +static SQInteger base_dummy(HSQUIRRELVM SQ_UNUSED_ARG(v)) { return 0; } @@ -296,7 +296,7 @@ static const SQRegFunction base_funcs[]={ {_SC("collectgarbage"),base_collectgarbage,0, NULL}, {_SC("resurrectunreachable"),base_resurectureachable,0, NULL}, #endif - {0,0} + {0,0,0,0} }; void sq_base_register(HSQUIRRELVM v) @@ -475,7 +475,7 @@ const SQRegFunction SQSharedState::_table_default_delegate_funcz[]={ {_SC("clear"),obj_clear,1, _SC(".")}, {_SC("setdelegate"),table_setdelegate,2, _SC(".t|o")}, {_SC("getdelegate"),table_getdelegate,1, _SC(".")}, - {0,0} + {0,0,0,0} }; //ARRAY DEFAULT DELEGATE/////////////////////////////////////// @@ -721,7 +721,7 @@ static bool _hsort_sift_down(HSQUIRRELVM v,SQArray *arr, SQInteger root, SQInteg return true; } -static bool _hsort(HSQUIRRELVM v,SQObjectPtr &arr, SQInteger l, SQInteger r,SQInteger func) +static bool _hsort(HSQUIRRELVM v,SQObjectPtr &arr, SQInteger SQ_UNUSED_ARG(l), SQInteger SQ_UNUSED_ARG(r),SQInteger func) { SQArray *a = _array(arr); SQInteger i; @@ -794,7 +794,7 @@ const SQRegFunction SQSharedState::_array_default_delegate_funcz[]={ {_SC("reduce"),array_reduce,2, _SC("ac")}, {_SC("filter"),array_filter,2, _SC("ac")}, {_SC("find"),array_find,2, _SC("a.")}, - {0,0} + {0,0,0,0} }; //STRING DEFAULT DELEGATE////////////////////////// @@ -863,7 +863,7 @@ const SQRegFunction SQSharedState::_string_default_delegate_funcz[]={ {_SC("tolower"),string_tolower,-1, _SC("s n n")}, {_SC("toupper"),string_toupper,-1, _SC("s n n")}, {_SC("weakref"),obj_delegate_weakref,1, NULL }, - {0,0} + {0,0,0,0} }; //INTEGER DEFAULT DELEGATE////////////////////////// @@ -873,7 +873,7 @@ const SQRegFunction SQSharedState::_number_default_delegate_funcz[]={ {_SC("tostring"),default_delegate_tostring,1, _SC(".")}, {_SC("tochar"),number_delegate_tochar,1, _SC("n|b")}, {_SC("weakref"),obj_delegate_weakref,1, NULL }, - {0,0} + {0,0,0,0} }; //CLOSURE DEFAULT DELEGATE////////////////////////// @@ -983,7 +983,7 @@ const SQRegFunction SQSharedState::_closure_default_delegate_funcz[]={ {_SC("getinfos"),closure_getinfos,1, _SC("c")}, {_SC("getroot"),closure_getroot,1, _SC("c")}, {_SC("setroot"),closure_setroot,2, _SC("ct")}, - {0,0} + {0,0,0,0} }; //GENERATOR DEFAULT DELEGATE @@ -1002,7 +1002,7 @@ const SQRegFunction SQSharedState::_generator_default_delegate_funcz[]={ {_SC("getstatus"),generator_getstatus,1, _SC("g")}, {_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("tostring"),default_delegate_tostring,1, _SC(".")}, - {0,0} + {0,0,0,0} }; //THREAD DEFAULT DELEGATE @@ -1162,7 +1162,7 @@ const SQRegFunction SQSharedState::_thread_default_delegate_funcz[] = { {_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("getstackinfos"),thread_getstackinfos,2, _SC("vn")}, {_SC("tostring"),default_delegate_tostring,1, _SC(".")}, - {0,0}, + {0,0,0,0}, }; static SQInteger class_getattributes(HSQUIRRELVM v) @@ -1229,7 +1229,7 @@ const SQRegFunction SQSharedState::_class_default_delegate_funcz[] = { {_SC("getbase"),class_getbase,1, _SC("y")}, {_SC("newmember"),class_newmember,-3, _SC("y")}, {_SC("rawnewmember"),class_rawnewmember,-3, _SC("y")}, - {0,0} + {0,0,0,0} }; @@ -1247,7 +1247,7 @@ const SQRegFunction SQSharedState::_instance_default_delegate_funcz[] = { {_SC("rawin"),container_rawexists,2, _SC("x")}, {_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("tostring"),default_delegate_tostring,1, _SC(".")}, - {0,0} + {0,0,0,0} }; static SQInteger weakref_ref(HSQUIRRELVM v) @@ -1261,6 +1261,6 @@ const SQRegFunction SQSharedState::_weakref_default_delegate_funcz[] = { {_SC("ref"),weakref_ref,1, _SC("r")}, {_SC("weakref"),obj_delegate_weakref,1, NULL }, {_SC("tostring"),default_delegate_tostring,1, _SC(".")}, - {0,0} + {0,0,0,0} }; diff --git a/squirrel/sqclass.cpp b/squirrel/sqclass.cpp index 6d588db..ec64b3d 100644 --- a/squirrel/sqclass.cpp +++ b/squirrel/sqclass.cpp @@ -189,7 +189,7 @@ SQInstance::~SQInstance() if(_class){ Finalize(); } //if _class is null it was already finalized by the GC } -bool SQInstance::GetMetaMethod(SQVM *v,SQMetaMethod mm,SQObjectPtr &res) +bool SQInstance::GetMetaMethod(SQVM SQ_UNUSED_ARG(*v),SQMetaMethod mm,SQObjectPtr &res) { if(type(_class->_metamethods[mm]) != OT_NULL) { res = _class->_metamethods[mm]; diff --git a/squirrel/sqcompiler.cpp b/squirrel/sqcompiler.cpp index 68b99ae..8a54d65 100644 --- a/squirrel/sqcompiler.cpp +++ b/squirrel/sqcompiler.cpp @@ -982,6 +982,7 @@ public: SQInteger val = _fs->PopTarget(); SQInteger key = _fs->PopTarget(); SQInteger attrs = hasattrs ? _fs->PopTarget():-1; + ((void)attrs); assert((hasattrs && (attrs == key-1)) || !hasattrs); unsigned char flags = (hasattrs?NEW_SLOT_ATTRIBUTES_FLAG:0)|(isstatic?NEW_SLOT_STATIC_FLAG:0); SQInteger table = _fs->TopTarget(); //< Date: Tue, 8 Mar 2016 14:43:19 +0100 Subject: [PATCH 2/8] Fix DLL installation with MSVC --- sq/CMakeLists.txt | 4 ++-- sqstdlib/CMakeLists.txt | 26 +++++++++++++------------- squirrel/CMakeLists.txt | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sq/CMakeLists.txt b/sq/CMakeLists.txt index 424ec9e..4609b0e 100644 --- a/sq/CMakeLists.txt +++ b/sq/CMakeLists.txt @@ -1,11 +1,11 @@ add_executable(sq sq.c) set_target_properties(sq PROPERTIES LINKER_LANGUAGE C) -target_link_libraries(sq squirrel sqstd) +target_link_libraries(sq squirrel sqstdlib) install(TARGETS sq RUNTIME DESTINATION bin) add_executable(sq_static sq.c) set_target_properties(sq_static PROPERTIES LINKER_LANGUAGE C) -target_link_libraries(sq_static squirrel_static sqstd_static) +target_link_libraries(sq_static squirrel_static sqstdlib_static) if(CMAKE_COMPILER_IS_GNUCXX) set_target_properties(sq_static PROPERTIES COMPILE_FLAGS "-static -Wl,-static") diff --git a/sqstdlib/CMakeLists.txt b/sqstdlib/CMakeLists.txt index 0a8f15e..78bed96 100644 --- a/sqstdlib/CMakeLists.txt +++ b/sqstdlib/CMakeLists.txt @@ -1,15 +1,15 @@ -set(SQSTD_SRC sqstdblob.cpp - sqstdio.cpp - sqstdstream.cpp - sqstdmath.cpp - sqstdsystem.cpp - sqstdstring.cpp - sqstdaux.cpp - sqstdrex.cpp) +set(SQSTDLIB_SRC sqstdblob.cpp + sqstdio.cpp + sqstdstream.cpp + sqstdmath.cpp + sqstdsystem.cpp + sqstdstring.cpp + sqstdaux.cpp + sqstdrex.cpp) -add_library(sqstd SHARED ${SQSTD_SRC}) -target_link_libraries(sqstd squirrel) -install(TARGETS sqstd LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) +add_library(sqstdlib SHARED ${SQSTDLIB_SRC}) +target_link_libraries(sqstdlib squirrel) +install(TARGETS sqstdlib RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) -add_library(sqstd_static STATIC ${SQSTD_SRC}) -install(TARGETS sqstd_static ARCHIVE DESTINATION lib) +add_library(sqstdlib_static STATIC ${SQSTDLIB_SRC}) +install(TARGETS sqstdlib_static ARCHIVE DESTINATION lib) diff --git a/squirrel/CMakeLists.txt b/squirrel/CMakeLists.txt index d47ca15..1ef3866 100644 --- a/squirrel/CMakeLists.txt +++ b/squirrel/CMakeLists.txt @@ -12,7 +12,7 @@ set(SQUIRREL_SRC sqapi.cpp sqclass.cpp) add_library(squirrel SHARED ${SQUIRREL_SRC}) -install(TARGETS squirrel LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) +install(TARGETS squirrel RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) add_library(squirrel_static STATIC ${SQUIRREL_SRC}) install(TARGETS squirrel_static ARCHIVE DESTINATION lib) From e9f7d4f264b9a96b51f82302994d7f7c89c7a519 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Wed, 9 Mar 2016 18:16:55 +0100 Subject: [PATCH 3/8] Add -Wcast-qual to g++ flags --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56cc53a..7657079 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ project(squirrel C CXX) include_directories(${CMAKE_SOURCE_DIR}/include) if(CMAKE_COMPILER_IS_GNUCXX) - set(SQ_FLAGS -fno-exceptions -fno-strict-aliasing -Wall -Wextra -pedantic) + set(SQ_FLAGS -fno-exceptions -fno-strict-aliasing -Wall -Wextra -pedantic -Wcast-qual) if(CMAKE_BUILD_TYPE STREQUAL "Release") set(SQ_FLAGS ${SQ_FLAGS} -O3) From 2592e50f83805ed0997b0d30c9a1f412e48a1684 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Sun, 13 Mar 2016 14:36:10 +0100 Subject: [PATCH 4/8] Implement more flexible installation --- CMakeLists.txt | 24 +++++++++++++++++++++++- COMPILE | 18 +++++++++++++++++- sq/CMakeLists.txt | 4 ++-- sqstdlib/CMakeLists.txt | 16 +++++++++------- squirrel/CMakeLists.txt | 20 +++++++++++--------- 5 files changed, 62 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7657079..add3193 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,8 +35,30 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) add_definitions(-D_SQ64) endif() +if(NOT DEFINED INSTALL_BIN_DIR) + set(INSTALL_BIN_DIR bin) +endif() + +if(NOT DEFINED INSTALL_LIB_DIR) + set(INSTALL_LIB_DIR lib) +endif() + add_subdirectory(squirrel) add_subdirectory(sqstdlib) add_subdirectory(sq) -install(FILES doc/squirrel3.pdf doc/sqstdlib3.pdf DESTINATION share/doc/squirrel3) +if(DEFINED INSTALL_DOC_DIR) + install(FILES doc/squirrel3.pdf doc/sqstdlib3.pdf DESTINATION ${INSTALL_DOC_DIR}) +endif() + +if(DEFINED INSTALL_INC_DIR) + set(SQ_PUB_HEADERS include/sqconfig.h + include/sqstdaux.h + include/sqstdblob.h + include/sqstdio.h + include/sqstdmath.h + include/sqstdstring.h + include/sqstdsystem.h + include/squirrel.h) + install(FILES ${SQ_PUB_HEADERS} DESTINATION ${INSTALL_INC_DIR}) +endif() diff --git a/COMPILE b/COMPILE index 05591a8..220999a 100644 --- a/COMPILE +++ b/COMPILE @@ -44,7 +44,23 @@ can change this behavior by calling CMake like this: $ cmake .. -DCMAKE_INSTALL_PREFIX=/some/path/on/your/system -Under Windows, it is probably easiest to use the CMake GUI interface. +With the INSTALL_BIN_DIR and INSTALL_LIB_DIR options, the directories +the binaries & libraries will go in (relative to CMAKE_INSTALL_PREFIX) +can be specified. For instance, + + $ cmake .. -DINSTALL_LIB_DIR=lib64 + +will install the libraries into a 'lib64' subdirectory in the top +source directory. If INSTALL_DOC_DIR is set, the PDF documentation +will be installed into the directory the value of INSTALL_DOC_DIR +points to. There is no default directory - if you want only the +binaries and no documentation, just don't specify INSTALL_DOC_DIR, and +no documentation will be installed. The same applies for +INSTALL_INC_DIR, which can install the public header files. + +Under Windows, it is probably easiest to use the CMake GUI interface, +although invoking CMake from the command line as explained above +should work as well. GCC USERS ......................................................... diff --git a/sq/CMakeLists.txt b/sq/CMakeLists.txt index 4609b0e..14d91e6 100644 --- a/sq/CMakeLists.txt +++ b/sq/CMakeLists.txt @@ -1,7 +1,7 @@ add_executable(sq sq.c) set_target_properties(sq PROPERTIES LINKER_LANGUAGE C) target_link_libraries(sq squirrel sqstdlib) -install(TARGETS sq RUNTIME DESTINATION bin) +install(TARGETS sq RUNTIME DESTINATION ${INSTALL_BIN_DIR}) add_executable(sq_static sq.c) set_target_properties(sq_static PROPERTIES LINKER_LANGUAGE C) @@ -11,4 +11,4 @@ if(CMAKE_COMPILER_IS_GNUCXX) set_target_properties(sq_static PROPERTIES COMPILE_FLAGS "-static -Wl,-static") endif() -install(TARGETS sq_static RUNTIME DESTINATION bin) +install(TARGETS sq_static RUNTIME DESTINATION ${INSTALL_BIN_DIR}) diff --git a/sqstdlib/CMakeLists.txt b/sqstdlib/CMakeLists.txt index 78bed96..ee60d99 100644 --- a/sqstdlib/CMakeLists.txt +++ b/sqstdlib/CMakeLists.txt @@ -1,15 +1,17 @@ -set(SQSTDLIB_SRC sqstdblob.cpp +set(SQSTDLIB_SRC sqstdaux.cpp + sqstdblob.cpp sqstdio.cpp - sqstdstream.cpp sqstdmath.cpp - sqstdsystem.cpp + sqstdrex.cpp + sqstdstream.cpp sqstdstring.cpp - sqstdaux.cpp - sqstdrex.cpp) + sqstdsystem.cpp) add_library(sqstdlib SHARED ${SQSTDLIB_SRC}) target_link_libraries(sqstdlib squirrel) -install(TARGETS sqstdlib RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) +install(TARGETS sqstdlib RUNTIME DESTINATION ${INSTALL_BIN_DIR} + LIBRARY DESTINATION ${INSTALL_LIB_DIR} + ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) add_library(sqstdlib_static STATIC ${SQSTDLIB_SRC}) -install(TARGETS sqstdlib_static ARCHIVE DESTINATION lib) +install(TARGETS sqstdlib_static ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) diff --git a/squirrel/CMakeLists.txt b/squirrel/CMakeLists.txt index 1ef3866..84c0d36 100644 --- a/squirrel/CMakeLists.txt +++ b/squirrel/CMakeLists.txt @@ -1,18 +1,20 @@ set(SQUIRREL_SRC sqapi.cpp sqbaselib.cpp - sqfuncstate.cpp - sqdebug.cpp - sqlexer.cpp - sqobject.cpp + sqclass.cpp sqcompiler.cpp + sqdebug.cpp + sqfuncstate.cpp + sqlexer.cpp + sqmem.cpp + sqobject.cpp sqstate.cpp sqtable.cpp - sqmem.cpp - sqvm.cpp - sqclass.cpp) + sqvm.cpp) add_library(squirrel SHARED ${SQUIRREL_SRC}) -install(TARGETS squirrel RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) +install(TARGETS squirrel RUNTIME DESTINATION ${INSTALL_BIN_DIR} + LIBRARY DESTINATION ${INSTALL_LIB_DIR} + ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) add_library(squirrel_static STATIC ${SQUIRREL_SRC}) -install(TARGETS squirrel_static ARCHIVE DESTINATION lib) +install(TARGETS squirrel_static ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) From c4749035499df2083ca3b19ab3e9142d54a5ccba Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Sun, 13 Mar 2016 15:08:25 +0100 Subject: [PATCH 5/8] Improve CMAKE_BUILD_TYPE handling --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index add3193..12bb6c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,8 +16,12 @@ if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_BUILD_TYPE STREQUAL "Release") set(SQ_FLAGS ${SQ_FLAGS} -O3) - else() - set(SQ_FLAGS ${SQ_FLAGS} -pg -pie -gstabs -g3) + elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + set(SQ_FLAGS ${SQ_FLAGS} -O3 -g) + elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") + set(SQ_FLAGS ${SQ_FLAGS} -Os) + elseif(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(SQ_FLAGS ${SQ_FLAGS} -pg -pie -gstabs -g3 -Og) endif() if(CMAKE_VERSION VERSION_GREATER 3) From b26f60fb2b42b12e2a8660873829545ad36da534 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Tue, 15 Mar 2016 23:11:11 +0100 Subject: [PATCH 6/8] Documentation can no longer be installed with CMake --- CMakeLists.txt | 4 ---- COMPILE | 11 +++++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12bb6c1..771519a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,10 +51,6 @@ add_subdirectory(squirrel) add_subdirectory(sqstdlib) add_subdirectory(sq) -if(DEFINED INSTALL_DOC_DIR) - install(FILES doc/squirrel3.pdf doc/sqstdlib3.pdf DESTINATION ${INSTALL_DOC_DIR}) -endif() - if(DEFINED INSTALL_INC_DIR) set(SQ_PUB_HEADERS include/sqconfig.h include/sqstdaux.h diff --git a/COMPILE b/COMPILE index 220999a..34244ed 100644 --- a/COMPILE +++ b/COMPILE @@ -33,7 +33,7 @@ under Linux, type something like $ mkdir build # Create temporary build directory $ cd build $ cmake .. # CMake will determine all the necessary information, - # including the platform (32- vs. 64-Bit) + # including the platform (32- vs. 64-bit) $ make $ make install $ cd ..; rm -r build @@ -51,12 +51,11 @@ can be specified. For instance, $ cmake .. -DINSTALL_LIB_DIR=lib64 will install the libraries into a 'lib64' subdirectory in the top -source directory. If INSTALL_DOC_DIR is set, the PDF documentation -will be installed into the directory the value of INSTALL_DOC_DIR +source directory. If INSTALL_INC_DIR is set, the public header files +will be installed into the directory the value of INSTALL_INC_DIR points to. There is no default directory - if you want only the -binaries and no documentation, just don't specify INSTALL_DOC_DIR, and -no documentation will be installed. The same applies for -INSTALL_INC_DIR, which can install the public header files. +binaries and no headers, just don't specify INSTALL_INC_DIR, and no +header files will be installed. Under Windows, it is probably easiest to use the CMake GUI interface, although invoking CMake from the command line as explained above From 89b5c519afe67de7e653099651824f2fe980dffd Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Wed, 16 Mar 2016 00:01:16 +0100 Subject: [PATCH 7/8] Improve Linux build --- CMakeLists.txt | 4 ++++ sq/CMakeLists.txt | 8 ++++++-- sqstdlib/CMakeLists.txt | 5 +++++ squirrel/CMakeLists.txt | 5 +++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 771519a..42185e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,10 @@ add_subdirectory(squirrel) add_subdirectory(sqstdlib) add_subdirectory(sq) +if(NOT WIN32) + set_target_properties(squirrel sqstdlib PROPERTIES SOVERSION 0 VERSION 0.0.0) +endif() + if(DEFINED INSTALL_INC_DIR) set(SQ_PUB_HEADERS include/sqconfig.h include/sqstdaux.h diff --git a/sq/CMakeLists.txt b/sq/CMakeLists.txt index 14d91e6..f7a4350 100644 --- a/sq/CMakeLists.txt +++ b/sq/CMakeLists.txt @@ -6,9 +6,13 @@ install(TARGETS sq RUNTIME DESTINATION ${INSTALL_BIN_DIR}) add_executable(sq_static sq.c) set_target_properties(sq_static PROPERTIES LINKER_LANGUAGE C) target_link_libraries(sq_static squirrel_static sqstdlib_static) +install(TARGETS sq_static RUNTIME DESTINATION ${INSTALL_BIN_DIR}) + +if(DEFINED LONG_OUTPUT_NAMES) + set_target_properties(sq PROPERTIES OUTPUT_NAME squirrel3) + set_target_properties(sq_static PROPERTIES OUTPUT_NAME squirrel3_static) +endif() if(CMAKE_COMPILER_IS_GNUCXX) set_target_properties(sq_static PROPERTIES COMPILE_FLAGS "-static -Wl,-static") endif() - -install(TARGETS sq_static RUNTIME DESTINATION ${INSTALL_BIN_DIR}) diff --git a/sqstdlib/CMakeLists.txt b/sqstdlib/CMakeLists.txt index ee60d99..0964e8f 100644 --- a/sqstdlib/CMakeLists.txt +++ b/sqstdlib/CMakeLists.txt @@ -15,3 +15,8 @@ install(TARGETS sqstdlib RUNTIME DESTINATION ${INSTALL_BIN_DIR} add_library(sqstdlib_static STATIC ${SQSTDLIB_SRC}) install(TARGETS sqstdlib_static ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) + +if(DEFINED LONG_OUTPUT_NAMES) + set_target_properties(sqstdlib PROPERTIES OUTPUT_NAME sqstdlib3) + set_target_properties(sqstdlib_static PROPERTIES OUTPUT_NAME sqstdlib3_static) +endif() diff --git a/squirrel/CMakeLists.txt b/squirrel/CMakeLists.txt index 84c0d36..649e1cc 100644 --- a/squirrel/CMakeLists.txt +++ b/squirrel/CMakeLists.txt @@ -18,3 +18,8 @@ install(TARGETS squirrel RUNTIME DESTINATION ${INSTALL_BIN_DIR} add_library(squirrel_static STATIC ${SQUIRREL_SRC}) install(TARGETS squirrel_static ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) + +if(DEFINED LONG_OUTPUT_NAMES) + set_target_properties(squirrel PROPERTIES OUTPUT_NAME squirrel3) + set_target_properties(squirrel_static PROPERTIES OUTPUT_NAME squirrel3_static) +endif() From ba57d3b5923b0751d47065f0e59459b8bea51546 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Thu, 17 Mar 2016 12:44:03 +0100 Subject: [PATCH 8/8] Add option to disable static targets --- sq/CMakeLists.txt | 17 +++++++++++------ sqstdlib/CMakeLists.txt | 11 ++++++++--- squirrel/CMakeLists.txt | 11 ++++++++--- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/sq/CMakeLists.txt b/sq/CMakeLists.txt index f7a4350..3d05006 100644 --- a/sq/CMakeLists.txt +++ b/sq/CMakeLists.txt @@ -3,16 +3,21 @@ set_target_properties(sq PROPERTIES LINKER_LANGUAGE C) target_link_libraries(sq squirrel sqstdlib) install(TARGETS sq RUNTIME DESTINATION ${INSTALL_BIN_DIR}) -add_executable(sq_static sq.c) -set_target_properties(sq_static PROPERTIES LINKER_LANGUAGE C) -target_link_libraries(sq_static squirrel_static sqstdlib_static) -install(TARGETS sq_static RUNTIME DESTINATION ${INSTALL_BIN_DIR}) +if(NOT DEFINED DISABLE_STATIC) + add_executable(sq_static sq.c) + set_target_properties(sq_static PROPERTIES LINKER_LANGUAGE C) + target_link_libraries(sq_static squirrel_static sqstdlib_static) + install(TARGETS sq_static RUNTIME DESTINATION ${INSTALL_BIN_DIR}) +endif() if(DEFINED LONG_OUTPUT_NAMES) set_target_properties(sq PROPERTIES OUTPUT_NAME squirrel3) - set_target_properties(sq_static PROPERTIES OUTPUT_NAME squirrel3_static) + + if(NOT DEFINED DISABLE_STATIC) + set_target_properties(sq_static PROPERTIES OUTPUT_NAME squirrel3_static) + endif() endif() -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND (NOT DEFINED DISABLE_STATIC)) set_target_properties(sq_static PROPERTIES COMPILE_FLAGS "-static -Wl,-static") endif() diff --git a/sqstdlib/CMakeLists.txt b/sqstdlib/CMakeLists.txt index 0964e8f..493b0a5 100644 --- a/sqstdlib/CMakeLists.txt +++ b/sqstdlib/CMakeLists.txt @@ -13,10 +13,15 @@ install(TARGETS sqstdlib RUNTIME DESTINATION ${INSTALL_BIN_DIR} LIBRARY DESTINATION ${INSTALL_LIB_DIR} ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) -add_library(sqstdlib_static STATIC ${SQSTDLIB_SRC}) -install(TARGETS sqstdlib_static ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) +if(NOT DEFINED DISABLE_STATIC) + add_library(sqstdlib_static STATIC ${SQSTDLIB_SRC}) + install(TARGETS sqstdlib_static ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) +endif() if(DEFINED LONG_OUTPUT_NAMES) set_target_properties(sqstdlib PROPERTIES OUTPUT_NAME sqstdlib3) - set_target_properties(sqstdlib_static PROPERTIES OUTPUT_NAME sqstdlib3_static) + + if(NOT DEFINED DISABLE_STATIC) + set_target_properties(sqstdlib_static PROPERTIES OUTPUT_NAME sqstdlib3_static) + endif() endif() diff --git a/squirrel/CMakeLists.txt b/squirrel/CMakeLists.txt index 649e1cc..6efef84 100644 --- a/squirrel/CMakeLists.txt +++ b/squirrel/CMakeLists.txt @@ -16,10 +16,15 @@ install(TARGETS squirrel RUNTIME DESTINATION ${INSTALL_BIN_DIR} LIBRARY DESTINATION ${INSTALL_LIB_DIR} ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) -add_library(squirrel_static STATIC ${SQUIRREL_SRC}) -install(TARGETS squirrel_static ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) +if(NOT DEFINED DISABLE_STATIC) + add_library(squirrel_static STATIC ${SQUIRREL_SRC}) + install(TARGETS squirrel_static ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) +endif() if(DEFINED LONG_OUTPUT_NAMES) set_target_properties(squirrel PROPERTIES OUTPUT_NAME squirrel3) - set_target_properties(squirrel_static PROPERTIES OUTPUT_NAME squirrel3_static) + + if(NOT DEFINED DISABLE_STATIC) + set_target_properties(squirrel_static PROPERTIES OUTPUT_NAME squirrel3_static) + endif() endif()