Make dynamic or static libraries optional

The user can choose static or dynamic libraries using
BUILD_STATIC_LIBRARIES and BUILD_DYNAMIC_LIBRARIES. By default
Windows will only build static libraries and Linux will build both.
This commit is contained in:
Matt Williams
2011-04-21 21:40:51 +02:00
parent f7f473126c
commit ac0fb2b310
9 changed files with 135 additions and 40 deletions

View File

@ -2,6 +2,35 @@ 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(BUILD_STATIC_LIBRARIES "Build static libraries" ON)
if(WIN32)
option(BUILD_DYNAMIC_LIBRARIES "Build dynamic libraries" OFF)
else()
option(BUILD_DYNAMIC_LIBRARIES "Build dynamic libraries" ON)
endif()
if(WIN32)
#If both are enabled then diable the dyanamic build
if(BUILD_STATIC_LIBRARIES AND BUILD_DYNAMIC_LIBRARIES)
message(STATUS "Building both static and dynamic libraries is not supported on Windows. Disabling dynamic libraries.")
set(BUILD_DYNAMIC_LIBRARIES OFF CACHE BOOL "Build dynamic libraries" FORCE)
endif()
#If both are diabled then re-enable the static build
if(NOT BUILD_STATIC_LIBRARIES AND NOT BUILD_DYNAMIC_LIBRARIES)
message(STATUS "Both dynamic and static libraries were disabled - re-enabling static build.")
set(BUILD_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 BUILD_STATIC_LIBRARIES AND NOT BUILD_DYNAMIC_LIBRARIES)
message(STATUS "Both dynamic and static libraries were disabled - re-enabling both.")
set(BUILD_STATIC_LIBRARIES ON CACHE BOOL "Build static libraries" FORCE)
set(BUILD_DYNAMIC_LIBRARIES ON CACHE BOOL "Build dynamic libraries" FORCE)
endif()
endif()
#add_subdirectory(bindings)
add_subdirectory(PolyVoxCore)
add_subdirectory(PolyVoxUtil)