Skip to content

Commit

Permalink
Merge pull request #524 from Bioinformatics/fix-csharp-build-flags-pu…
Browse files Browse the repository at this point in the history
…blic

IPA-6026: Fix visual studio compile options for C#
  • Loading branch information
ezralanglois authored and GitHub Enterprise committed Jan 24, 2017
2 parents 689edf9 + cf975bf commit a6ec230
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ project(InterOp)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
enable_testing()
include(${PROJECT_SOURCE_DIR}/cmake/Modules/UseGitVersion.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/InternalUtils.cmake)
set(ARCHIVE_VERSION "v1.0.13-src")


Expand All @@ -12,7 +11,6 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

interop_config_compiler_and_linker()
# TODO: https://help.github.com/articles/creating-project-pages-manually/

# TODO: Handle Windows Shared libs: https://cmake.org/Wiki/BuildingWinDLL
Expand All @@ -29,9 +27,12 @@ option(ENABLE_APPS "Build command line programs" ON)
option(ENABLE_EXAMPLES "Build example programs" ON)
option(ENABLE_STATIC "Build static libraries instead of dynamic" ON)
option(FORCE_X86 "Force 32-bit libraries instead of platform default (Does nothing for Visual Studio)" OFF)
option(FORCE_SHARED_CRT "Used the shared (DLL) run time lib" ON)
option(FORCE_SHARED_CRT "Used the shared (DLL) run time lib (must be ON if compiling for C#)" ON)
option(ENABLE_CSHARP "Build C# language bindings" ON)

include(${PROJECT_SOURCE_DIR}/cmake/InternalUtils.cmake)
interop_config_compiler_and_linker()

# Options to control integration builds
set(PACKAGE_SUFFIX "" CACHE STRING "Suffix added to the output packages")
set(BUILD_NUMBER "" CACHE STRING "Build number used for select packing scripts")
Expand Down Expand Up @@ -77,8 +78,10 @@ include(CPack)

if(ENABLE_STATIC)
set(LIBRARY_TYPE STATIC)
set(BUILD_SHARED_LIBS OFF)
else()
set(LIBRARY_TYPE SHARED)
set(BUILD_SHARED_LIBS ON)
endif()

if(WIN32 AND ${LIBRARY_TYPE} STREQUAL "SHARED")
Expand Down
14 changes: 7 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
#
# Visual Studio 14 2015
# - Release/Debug
# - 32-bit/64-bit
# - 64-bit
# Visual Studio 12 2013
# - Release/Debug
# - 32-bit/64-bit
# - 64-bit
# MinGW
# - Release/Debug
# - 64-bit
#
# Removed support for 32-bit MinGW
# Removed support for 32-bit compilers
#
# C# Compiler is always .NET v4.0.30319
#
Expand All @@ -40,9 +40,9 @@ environment:
# - generator: "Visual Studio 14 2015"
# BUILD: msvc14_win32
# config_type: win32
- generator: "Visual Studio 12 2013 Win64"
BUILD: msvc12_win64
config_type: win64_not_supported
# - generator: "Visual Studio 12 2013 Win64"
# BUILD: msvc12_win64
# config_type: win64
# - generator: "Visual Studio 12 2013"
# BUILD: msvc12_win32
# config_type: win32
Expand Down Expand Up @@ -73,7 +73,7 @@ install:
build_script:
- set BUILD_PATH=%CD%\%BUILD%_%configuration%
- cmake --version
- cmake ../ -G "%GENERATOR%" -H. -Bbuild -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_INSTALL_PREFIX=%BUILD_PATH% -DFORCE_SHARED_CRT=OFF
- cmake ../ -G "%GENERATOR%" -H. -Bbuild -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_INSTALL_PREFIX=%BUILD_PATH%
- cmake --build build --config "%configuration%"
- cmake --build build --config "%configuration%" --target install

Expand Down
3 changes: 3 additions & 0 deletions cmake/InternalUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# update variables in the function scope.
macro(fix_default_compiler_settings_)
if (MSVC)
if (NOT BUILD_SHARED_LIBS AND NOT FORCE_SHARED_CRT)
message(STATUS "Replacing MD with MT")
endif()
# For MSVC, CMake sets certain flags to defaults we want to override.
# This replacement code is taken from sample in the CMake Wiki at
# http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace.
Expand Down
4 changes: 4 additions & 0 deletions src/ext/csharp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ if(NOT CSHARP_FOUND)
return()
endif()

if(NOT FORCE_SHARED_CRT)
message(FATAL_ERROR "-DFORCE_SHARED_CRT=OFF is not supported for CSharp bindings. Either set -DENABLE_CSHARP=OFF or -DFORCE_SHARED_CRT=ON")
endif()

include(${CSHARP_USE_FILE})

set(SWIG_GEN_CSHARP_SOURCE_FILES ${CMAKE_SWIG_OUTDIR}/*.cs CACHE INTERNAL "C# source files generated by SWIG" FORCE)
Expand Down
4 changes: 2 additions & 2 deletions tools/regression_test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ if($lib_path) { $build_param="-DGTEST_ROOT=$lib_path -DJUNIT_ROOT=$lib_path -DGM
Write-Host "##teamcity[blockOpened name='Configure $config $generator']"
new-item build_vs2015_x64_$config -itemtype directory
set-location -path build_vs2015_x64_$config
Write-Host "cmake $source_path -G $generator -DCMAKE_BUILD_TYPE=$config $build_param -DFORCE_SHARED_CRT=OFF"
cmake $source_path -G $generator -DCMAKE_BUILD_TYPE=$config $build_param -DFORCE_SHARED_CRT=OFF
Write-Host "cmake $source_path -G $generator -DCMAKE_BUILD_TYPE=$config $build_param"
cmake $source_path -G $generator -DCMAKE_BUILD_TYPE=$config $build_param
$test_code=$lastexitcode
Write-Host "##teamcity[blockClosed name='Configure $config $generator']"
if ($test_code -ne 0)
Expand Down

0 comments on commit a6ec230

Please sign in to comment.