Implement more flexible installation

This commit is contained in:
Fabian Wolff 2016-03-13 14:36:10 +01:00
parent e9f7d4f264
commit 2592e50f83
5 changed files with 62 additions and 20 deletions

View File

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

18
COMPILE
View File

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

View File

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

View File

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

View File

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