From 2592e50f83805ed0997b0d30c9a1f412e48a1684 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Sun, 13 Mar 2016 14:36:10 +0100 Subject: [PATCH] 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})