Skip to content

Commit

Permalink
Merge pull request #3960 from NREL/Dotnet_updated
Browse files Browse the repository at this point in the history
SWIG C# fixes + dotnet support
  • Loading branch information
kbenne authored Jun 2, 2020
2 parents 97129fb + 28fa405 commit f339397
Show file tree
Hide file tree
Showing 42 changed files with 848 additions and 221 deletions.
25 changes: 7 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,8 @@ option(BUILD_PAT "Build PAT" OFF)
option(BUILD_DOCUMENTATION "Build Documentation" OFF)

# Build CSharp bindings
# Requires: SWIG
if(WIN32)
option(BUILD_CSHARP_BINDINGS "Build CSharp bindings" OFF)
endif()
option(BUILD_CSHARP_BINDINGS "Build CSharp bindings" OFF)
option(BUILD_NUGET_PACKAGE "Build NuGet Package" OFF)

# Build Java bindings
# Requires: SWIG
Expand All @@ -263,10 +261,6 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_definitions(-Qunused-arguments)
endif()

if(WIN32)
option(BUILD_NUGET_PACKAGE "Build NuGet Package" OFF)
endif()

# Enable runtime checking features
if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
option(ENABLE_THREAD_SANITIZER "Enable thread sanitizer testing in gcc/clang" OFF)
Expand Down Expand Up @@ -350,10 +344,10 @@ option(CONAN_PRINT_RUN_COMMANDS "Log every conan self.run command" OFF)
mark_as_advanced(CONAN_PRINT_RUN_COMMANDS)
if(CONAN_PRINT_RUN_COMMANDS)
set(ENV{CONAN_PRINT_RUN_COMMANDS} "1")
message("Setting CONAN_PRINT_RUN_COMMANDS: $ENV{CONAN_PRINT_RUN_COMMANDS}")
message(STATUS "Setting CONAN_PRINT_RUN_COMMANDS: $ENV{CONAN_PRINT_RUN_COMMANDS}")
else()
unset(ENV{CONAN_PRINT_RUN_COMMANDS})
message("CONAN_PRINT_RUN_COMMANDS: $ENV{CONAN_PRINT_RUN_COMMANDS}")
message(STATUS "CONAN_PRINT_RUN_COMMANDS: $ENV{CONAN_PRINT_RUN_COMMANDS}")
endif()

# Attempt to run, it'll do the right thing if the calling cmake script already ran it
Expand Down Expand Up @@ -1364,14 +1358,9 @@ if(BUILD_PAT)
)
endif()

if( BUILD_NUGET_PACKAGE )
configure_file( OpenStudio.nuspec.in OpenStudio.nuspec )

add_custom_target(nuget_package
COMMAND NuGet pack OpenStudio.nuspec -BasePath "${PROJECT_BINARY_DIR}/" -properties Configuration=$<CONFIGURATION>
DEPENDS csharp_sdk
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
)
if( BUILD_NUGET_PACKAGE AND NOT BUILD_CSHARP_BINDINGS)
message("If BUILD_NUGET_PACKAGE=ON, you must use BUILD_CSHARP_BINDINGS=ON too")
# Rest moved to csharp/CMakeLists.txt
endif()


Expand Down
18 changes: 15 additions & 3 deletions ProjectMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -589,13 +589,25 @@ macro(MAKE_SWIG_TARGET NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PARENT_S

list(FIND translator_names ${NAME} name_found)
if( name_found GREATER -1 )
set(CSHARP_OUTPUT_NAME "openstudio_translators_csharp.dll")
if(MSVC)
set(CSHARP_OUTPUT_NAME "openstudio_translators_csharp.dll")
else()
set(CSHARP_OUTPUT_NAME "libopenstudio_translators_csharp.so")
endif()
else()
list(FIND model_names ${NAME} name_found)
if( name_found GREATER -1 )
set(CSHARP_OUTPUT_NAME "openstudio_model_csharp.dll")
if(MSVC)
set(CSHARP_OUTPUT_NAME "openstudio_model_csharp.dll")
else()
set(CSHARP_OUTPUT_NAME "libopenstudio_model_csharp.so")
endif()
else()
set(CSHARP_OUTPUT_NAME "openstudio_csharp.dll")
if(MSVC)
set(CSHARP_OUTPUT_NAME "openstudio_csharp.dll")
else()
set(CSHARP_OUTPUT_NAME "libopenstudio_csharp.so")
endif()
endif()
endif()

Expand Down
Loading

0 comments on commit f339397

Please sign in to comment.