Build only one of static or shared libraries

As discussed on the forums, to simplify the CMake code and avoid having to
manually specify dependencies this removes the hack to allow both static
and shared libraries to be built at the same time.

It introduces the new variable LIBRARY_TYPE which can be either STATIC or
DYNAMIC.

See: http://www.volumesoffun.com/phpBB3/viewtopic.php?p=3203#p3203
This commit is contained in:
Matt Williams
2012-07-19 17:33:34 +01:00
parent 5d93eef5ac
commit f11b4e17c1
6 changed files with 48 additions and 150 deletions

View File

@ -2,35 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(PolyVox)
#By default only build static libraries on Windows but both on Linux
#If we ever require CMake 2.8 then use http://www.kitware.com/blog/home/post/82
option(ENABLE_STATIC_LIBRARIES "Build static libraries" ON)
if(WIN32)
option(ENABLE_DYNAMIC_LIBRARIES "Build dynamic libraries" OFF)
else()
option(ENABLE_DYNAMIC_LIBRARIES "Build dynamic libraries" ON)
endif()
if(WIN32)
#If both are enabled then diable the dyanamic build
if(ENABLE_STATIC_LIBRARIES AND ENABLE_DYNAMIC_LIBRARIES)
message(STATUS "Building both static and dynamic libraries is not supported on Windows. Disabling dynamic libraries.")
set(ENABLE_DYNAMIC_LIBRARIES OFF CACHE BOOL "Build dynamic libraries" FORCE)
endif()
#If both are diabled then re-enable the static build
if(NOT ENABLE_STATIC_LIBRARIES AND NOT ENABLE_DYNAMIC_LIBRARIES)
message(STATUS "Both dynamic and static libraries were disabled - re-enabling static build.")
set(ENABLE_STATIC_LIBRARIES ON CACHE BOOL "Build static libraries" FORCE)
endif()
else()
#It's nonsense to disble both so on Linux, re-enable both.
if(NOT ENABLE_STATIC_LIBRARIES AND NOT ENABLE_DYNAMIC_LIBRARIES)
message(STATUS "Both dynamic and static libraries were disabled - re-enabling both.")
set(ENABLE_STATIC_LIBRARIES ON CACHE BOOL "Build static libraries" FORCE)
set(ENABLE_DYNAMIC_LIBRARIES ON CACHE BOOL "Build dynamic libraries" FORCE)
endif()
endif()
add_subdirectory(PolyVoxCore)
add_subdirectory(PolyVoxUtil)
add_subdirectory(bindings)