mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-01 03:00:13 -04:00
C# "works" on windows - "works" meaning that it compiles, but some parts don't yet work properly. Example runs, but many failures
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
@@ -169,6 +169,7 @@ if (COOLPROP_OCTAVE_MODULE)
|
||||
# Find the required libraries
|
||||
find_library(OCTAVE_LIB octave PATHS ${OCTAVE_LINK_DIRS})
|
||||
find_library(OCTINTERP_LIB octinterp PATHS ${OCTAVE_LINK_DIRS})
|
||||
find_library(CRUFT_LIB cruft PATHS ${OCTAVE_LINK_DIRS})
|
||||
|
||||
# Set the include folders
|
||||
SET(OCTAVE_WRAP_INCLUDE_DIRS ${INCLUDE_DIR})
|
||||
@@ -181,13 +182,33 @@ if (COOLPROP_OCTAVE_MODULE)
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(${I_FILE} PROPERTIES CPLUSPLUS ON)
|
||||
SWIG_ADD_MODULE(CoolProp octave ${I_FILE} ${APP_SOURCES})
|
||||
SWIG_LINK_LIBRARIES(CoolProp ${OCTAVE_LIB} ${OCTINTERP_LIB})
|
||||
SWIG_LINK_LIBRARIES(CoolProp ${OCTAVE_LIB} ${OCTINTERP_LIB} ${CRUFT_LIB})
|
||||
|
||||
add_dependencies (CoolProp generate_headers)
|
||||
set_target_properties(CoolProp PROPERTIES SUFFIX ".oct" PREFIX "")
|
||||
|
||||
endif()
|
||||
|
||||
if (COOLPROP_CSHARP_MODULE)
|
||||
|
||||
# Must have SWIG and Octave
|
||||
FIND_PACKAGE(SWIG REQUIRED)
|
||||
INCLUDE(${SWIG_USE_FILE})
|
||||
FIND_PACKAGE(Csharp REQUIRED)
|
||||
|
||||
# Make a src directory to deal with file permissions problem with MinGW makefile
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||
|
||||
set(I_FILE "${CMAKE_SOURCE_DIR}/src/CoolProp.i")
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(${I_FILE} PROPERTIES CPLUSPLUS ON)
|
||||
SET_SOURCE_FILES_PROPERTIES(${I_FILE} PROPERTIES SWIG_FLAGS "-dllimport \"CoolProp\"")
|
||||
|
||||
SWIG_ADD_MODULE(CoolProp csharp ${I_FILE} ${APP_SOURCES})
|
||||
|
||||
set_target_properties(CoolProp PROPERTIES PREFIX "")
|
||||
|
||||
endif()
|
||||
|
||||
# NOT WORKING!
|
||||
if (COOLPROP_MATHEMATICA_MODULE)
|
||||
|
||||
|
||||
72
dev/cmake/Modules/FindCsharp.cmake
Normal file
72
dev/cmake/Modules/FindCsharp.cmake
Normal file
@@ -0,0 +1,72 @@
|
||||
#
|
||||
# A CMake Module for finding and using C# (.NET and Mono).
|
||||
#
|
||||
# The following variables are set:
|
||||
# CSHARP_FOUND - set to ON if C# is found
|
||||
# CSHARP_USE_FILE - the path to the C# use file
|
||||
# CSHARP_TYPE - the type of the C# compiler (eg. ".NET" or "Mono")
|
||||
# CSHARP_VERSION - the version of the C# compiler (eg. "v4.0" or "2.10.2")
|
||||
# CSHARP_COMPILER - the path to the C# compiler executable (eg. "C:/Windows/Microsoft.NET/Framework/v4.0.30319/csc.exe" or "/usr/bin/gmcs")
|
||||
# CSHARP_INTERPRETER - the path to interpreter needed to run CSharp executables
|
||||
# CSHARP_PLATFORM - the C# target platform
|
||||
# CSHARP_SDK - the SDK commandline switch (empty for .NET, for Mono eg. "/sdk:2" or "/sdk:4")
|
||||
#
|
||||
# This file is based on the work of GDCM:
|
||||
# http://gdcm.svn.sf.net/viewvc/gdcm/trunk/CMake/FindCSharp.cmake
|
||||
# Copyright (c) 2006-2010 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||
#
|
||||
|
||||
# TODO: ADD ABILITY TO SELECT WHICH C# COMPILER eg. .NET or Mono (if both exist). For the moment, .NET is selected above Mono.
|
||||
|
||||
# Make sure find package macros are included
|
||||
include( FindPackageHandleStandardArgs )
|
||||
|
||||
unset( CSHARP_COMPILER CACHE )
|
||||
unset( CSHARP_INTERPRETER CACHE )
|
||||
unset( CSHARP_TYPE CACHE )
|
||||
unset( CSHARP_VERSION CACHE )
|
||||
unset( CSHARP_FOUND CACHE )
|
||||
|
||||
# By default use anycpu platform, allow the user to override
|
||||
set( CSHARP_PLATFORM "anycpu" CACHE STRING "C# target platform: x86, x64, anycpu, or itanium" )
|
||||
if( NOT ${CSHARP_PLATFORM} MATCHES "x86|x64|anycpu|itanium" )
|
||||
message( FATAL_ERROR "The C# target platform '${CSHARP_PLATFORM}' is not valid. Please enter one of the following: x86, x64, anycpu, or itanium" )
|
||||
endif( )
|
||||
|
||||
if( WIN32 )
|
||||
find_package( DotNetFrameworkSdk )
|
||||
if( NOT CSHARP_DOTNET_FOUND )
|
||||
find_package( Mono )
|
||||
endif( )
|
||||
else( UNIX )
|
||||
find_package( Mono )
|
||||
endif( )
|
||||
|
||||
if( CSHARP_DOTNET_FOUND )
|
||||
set( CSHARP_TYPE ".NET" CACHE STRING "Using the .NET compiler" )
|
||||
set( CSHARP_VERSION ${CSHARP_DOTNET_VERSION} CACHE STRING "C# .NET compiler version" FORCE )
|
||||
set( CSHARP_COMPILER ${CSHARP_DOTNET_COMPILER_${CSHARP_DOTNET_VERSION}} CACHE STRING "Full path to .NET compiler" FORCE )
|
||||
set( CSHARP_INTERPRETER "" CACHE INTERNAL "Interpretor not required for .NET" FORCE )
|
||||
elseif( CSHARP_MONO_FOUND )
|
||||
set( CSHARP_TYPE "Mono" CACHE STRING "Using the Mono compiler" )
|
||||
set( CSHARP_VERSION ${CSHARP_MONO_VERSION} CACHE STRING "C# Mono compiler version" FORCE )
|
||||
set( CSHARP_COMPILER ${CSHARP_MONO_COMPILER_${CSHARP_MONO_VERSION}} CACHE STRING "Full path to Mono compiler" FORCE )
|
||||
set( CSHARP_INTERPRETER ${CSHARP_MONO_INTERPRETER_${CSHARP_MONO_VERSION}} CACHE STRING "Full path to Mono interpretor" FORCE )
|
||||
set( CSHARP_SDK "/sdk:2" CACHE STRING "C# Mono SDK commandline switch (e.g. /sdk:2, /sdk:4, /sdk:5)" )
|
||||
endif( )
|
||||
|
||||
# Handle WIN32 specific issues
|
||||
if ( WIN32 )
|
||||
if ( CSHARP_COMPILER MATCHES "bat" )
|
||||
set( CSHARP_COMPILER "call ${CSHARP_COMPILER}" )
|
||||
endif ( )
|
||||
endif( )
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CSharp DEFAULT_MSG CSHARP_TYPE CSHARP_VERSION CSHARP_COMPILER)
|
||||
|
||||
mark_as_advanced( CSHARP_TYPE CSHARP_VERSION CSHARP_COMPILER CSHARP_INTERPRETER CSHARP_PLATFORM CSHARP_SDK )
|
||||
|
||||
# Set the USE_FILE path
|
||||
# http://public.kitware.com/Bug/view.php?id=7757
|
||||
get_filename_component( current_list_path ${CMAKE_CURRENT_LIST_FILE} PATH )
|
||||
set( CSHARP_USE_FILE ${current_list_path}/UseCSharp.cmake )
|
||||
92
dev/cmake/Modules/FindDotNetFrameworkSdk.cmake
Normal file
92
dev/cmake/Modules/FindDotNetFrameworkSdk.cmake
Normal file
@@ -0,0 +1,92 @@
|
||||
#
|
||||
# A CMake Module for finding C# .NET.
|
||||
#
|
||||
# The following variables are set:
|
||||
# CSHARP_DOTNET_FOUND
|
||||
# CSHARP_DOTNET_COMPILER_${version} eg. "CSHARP_DOTNET_COMPILER_v4.0.30319"
|
||||
# CSHARP_DOTNET_VERSION eg. "v4.0.30319"
|
||||
# CSHARP_DOTNET_VERSIONS eg. "v2.0.50727, v3.5, v4.0.30319"
|
||||
# DotNetFrameworkSdk_USE_FILE
|
||||
#
|
||||
# Additional references can be found here:
|
||||
# .NET SDK 1.1: http://www.microsoft.com/downloads/details.aspx?FamilyID=9b3a2ca6-3647-4070-9f41-a333c6b9181d&displaylang=en
|
||||
# .NET SDK 2.0: http://www.microsoft.com/downloads/details.aspx?FamilyID=fe6f2099-b7b4-4f47-a244-c96d69c35dec&displaylang=en
|
||||
# .NET SDK 3.5: http://www.microsoft.com/downloads/details.aspx?familyid=333325fd-ae52-4e35-b531-508d977d32a6&displaylang=en
|
||||
# C# Compiler options: http://msdn.microsoft.com/en-us/library/2fdbz5xd(v=VS.71).aspx
|
||||
#
|
||||
# This file is based on the work of GDCM:
|
||||
# http://gdcm.svn.sf.net/viewvc/gdcm/trunk/CMake/FindDotNETFrameworkSDK.cmake
|
||||
# Copyright (c) 2006-2010 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||
#
|
||||
|
||||
set( csharp_dotnet_valid 1 )
|
||||
if( DEFINED CSHARP_DOTNET_FOUND )
|
||||
# The .NET compiler has already been found
|
||||
# It may have been reset by the user, verify it is correct
|
||||
if( NOT DEFINED CSHARP_DOTNET_COMPILER_${CSHARP_DOTNET_VERSION} )
|
||||
set( csharp_dotnet_version_user ${CSHARP_DOTNET_VERSION} )
|
||||
set( csharp_dotnet_valid 0 )
|
||||
set( CSHARP_DOTNET_FOUND 0 )
|
||||
set( CSHARP_DOTNET_VERSION "CSHARP_DOTNET_VERSION-NOTVALID" CACHE STRING "C# .NET compiler version, choices: ${CSHARP_DOTNET_VERSIONS}" FORCE )
|
||||
message( FATAL_ERROR "The C# .NET version '${csharp_dotnet_version_user}' is not valid. Please enter one of the following: ${CSHARP_DOTNET_VERSIONS}" )
|
||||
endif( )
|
||||
endif( )
|
||||
|
||||
unset( CSHARP_DOTNET_VERSIONS CACHE ) # Clear versions
|
||||
|
||||
# Get the framework directory based on platform
|
||||
if( ${CSHARP_PLATFORM} MATCHES "x64|itanium" )
|
||||
set( csharp_dotnet_framework_dir "$ENV{windir}/Microsoft.NET/Framework64" )
|
||||
else( )
|
||||
set( csharp_dotnet_framework_dir "$ENV{windir}/Microsoft.NET/Framework" )
|
||||
endif( )
|
||||
|
||||
# Search for .NET versions
|
||||
string( REPLACE "\\" "/" csharp_dotnet_framework_dir ${csharp_dotnet_framework_dir} )
|
||||
file( GLOB_RECURSE csharp_dotnet_executables "${csharp_dotnet_framework_dir}/csc.exe" )
|
||||
list( SORT csharp_dotnet_executables )
|
||||
list( REVERSE csharp_dotnet_executables )
|
||||
foreach ( csharp_dotnet_executable ${csharp_dotnet_executables} )
|
||||
if( csharp_dotnet_valid )
|
||||
# Extract version number (eg. v4.0.30319)
|
||||
# TODO: Consider using REGEX
|
||||
string( REPLACE "${csharp_dotnet_framework_dir}/" "" csharp_dotnet_version_temp ${csharp_dotnet_executable} )
|
||||
string( REPLACE "/csc.exe" "" csharp_dotnet_version_temp ${csharp_dotnet_version_temp} )
|
||||
|
||||
# Add variable holding executable
|
||||
set( CSHARP_DOTNET_COMPILER_${csharp_dotnet_version_temp} ${csharp_dotnet_executable} CACHE STRING "C# .NET compiler ${csharp_dotnet_version}" FORCE )
|
||||
mark_as_advanced( CSHARP_DOTNET_COMPILER_${csharp_dotnet_version_temp} )
|
||||
endif( )
|
||||
|
||||
# Create a list of supported compiler versions
|
||||
if( NOT DEFINED CSHARP_DOTNET_VERSIONS )
|
||||
set( CSHARP_DOTNET_VERSIONS "${csharp_dotnet_version_temp}" CACHE STRING "Available C# .NET compiler versions" FORCE )
|
||||
else( )
|
||||
set( CSHARP_DOTNET_VERSIONS "${CSHARP_DOTNET_VERSIONS}, ${csharp_dotnet_version_temp}" CACHE STRING "Available C# .NET compiler versions" FORCE )
|
||||
endif( )
|
||||
mark_as_advanced( CSHARP_DOTNET_VERSIONS )
|
||||
|
||||
# We found at least one .NET compiler version
|
||||
set( CSHARP_DOTNET_FOUND 1 CACHE INTERNAL "Boolean indicating if C# .NET was found" )
|
||||
endforeach( csharp_dotnet_executable )
|
||||
|
||||
if( CSHARP_DOTNET_FOUND )
|
||||
# Report the found versions
|
||||
message( STATUS "Found the following C# .NET versions: ${CSHARP_DOTNET_VERSIONS}" )
|
||||
|
||||
# Set the compiler version
|
||||
# Do not force, so that the user can manually select their own version if they wish
|
||||
if ( DEFINED CSHARP_DOTNET_COMPILER_v2.0.50727 )
|
||||
# If available, select .NET v2.0.50727 (this is the minimal version as it supports generics, and allows use of VS2008)
|
||||
set( CSHARP_DOTNET_VERSION "v2.0.50727" CACHE STRING "C# .NET compiler version" )
|
||||
else( )
|
||||
# Select the highest version (first in reverse sorted list)
|
||||
list( GET CSHARP_DOTNET_VERSIONS 0 csharp_dotnet_version_temp )
|
||||
set( CSHARP_DOTNET_VERSION ${csharp_dotnet_version_temp} CACHE STRING "C# .NET compiler version" )
|
||||
endif( )
|
||||
mark_as_advanced( CSHARP_DOTNET_VERSION )
|
||||
endif( )
|
||||
|
||||
# Set USE_FILE
|
||||
get_filename_component( current_list_path ${CMAKE_CURRENT_LIST_FILE} PATH )
|
||||
set( DotNetFrameworkSdk_USE_FILE ${current_list_path}/UseDotNetFrameworkSdk.cmake )
|
||||
Reference in New Issue
Block a user