Extend copile support for MSVC.

- Add an option to choose between dynamic or static library version of libconfig++
- Add an option to choose linking the runtime against dynamic or static CRT library
This commit is contained in:
kai
2012-10-17 06:56:52 +02:00
parent 79e0b53fe7
commit 641f0f9964
2 changed files with 21 additions and 2 deletions

View File

@@ -3,6 +3,10 @@ cmake_minimum_required(VERSION 2.6)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")
if(MSVC)
set(LIBCONFIG_DLL OFF CACHE BOOL "Use libconfig++ DLL instead of static library")
endif(MSVC)
#
# Locate LLVM.
#
@@ -217,6 +221,9 @@ include_directories(
if(MSVC)
include_directories(${PROJECT_SOURCE_DIR}/vcbuild)
if(NOT LIBCONFIG_DLL)
add_definitions(-DLIBCONFIGXX_STATIC -DLIBCONFIG_STATIC)
endif()
endif()
add_definitions(

View File

@@ -26,6 +26,9 @@ set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/d
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build as shared library or as static library")
set(CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} CACHE PATH "Directory where lib will be installed")
set(D_FLAGS -g -w -d CACHE STRING "runtime build flags, separated by ;")
if(MSVC)
set(LINK_WITH_MSVCRT OFF CACHE BOOL "Link with MSVCRT.LIB instead of LIBCMT.LIB")
endif()
if(BUILD_SHARED_LIBS)
list(APPEND D_FLAGS -relocation-model=pic)
@@ -387,10 +390,19 @@ endmacro(build_runtime d_flags c_flags ld_flags lib_suffix path_suffix)
if(PHOBOS2_DIR)
add_custom_target(phobos2)
endif(PHOBOS2_DIR)
build_runtime("" "" "${LD_FLAGS}" "" "${LIB_SUFFIX}")
if(MSVC)
if (LINK_WITH_MSVCRT)
set(RT_CFLAGS "/MDd")
else()
set(RT_CFLAGS "/MTd")
endif()
else()
set(RT_CFLAGS "")
endif()
build_runtime("" "${RT_CLAGS}" "${LD_FLAGS}" "" "${LIB_SUFFIX}")
set(GENERATE_DI "")
if(MULTILIB)
build_runtime("-m${MULTILIB_SUFFIX}" "-m${MULTILIB_SUFFIX}" "-m${MULTILIB_SUFFIX} ${LD_FLAGS}" "" "${MULTILIB_SUFFIX}")
build_runtime("-m${MULTILIB_SUFFIX}" "-m${MULTILIB_SUFFIX} ${RT_CFLAGS}" "-m${MULTILIB_SUFFIX} ${LD_FLAGS}" "" "${MULTILIB_SUFFIX}")
endif(MULTILIB)
#