Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 65 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.0)
cmake_minimum_required(VERSION 3.20)

#######################################
# PROJECT INFORMATION #
Expand All @@ -16,7 +16,7 @@ function(get_version file_name output)
#message(STATUS "[${PROJECT_NAME}] - Found version number: ${FIRST_MATCH}")
string(REGEX MATCH "[0-9]\\.[0-9]\\.[0-9]" SECOND_MATCH "${FIRST_MATCH}")
if(SECOND_MATCH)
message(STATUS "[${PROJECT_NAME}] - Found version number: ${SECOND_MATCH}")
message(STATUS "[IF97] - Found version number: ${SECOND_MATCH}")
set(${output} ${SECOND_MATCH} PARENT_SCOPE)
else()
message(FATAL_ERROR "Data were not found for the required build specification.")
Expand All @@ -25,11 +25,11 @@ endfunction()

get_version("${CMAKE_CURRENT_LIST_DIR}/IF97.h" VERSION)


# Project name
project("IF97" LANGUAGES CXX VERSION ${VERSION})

message(STATUS "[${PROJECT_NAME}] - Building v${PROJECT_VERSION} of ${PROJECT_NAME}")
string(REPLACE "." "," IF97_VERSION "${VERSION}")

option(IF97_PRIME_MODULE "Build MathCAD Prime wrapper" OFF)
option(IF97_MATHCAD15_MODULE "Build MathCAD 15 wrapper" OFF)
Expand Down Expand Up @@ -75,17 +75,76 @@ endif()
# MATHCAD PRIME MODULE #
#########################
if(IF97_PRIME_MODULE)
# Make sure we're on Winows - the only platform on which Mathad Prime runs
if(NOT WIN32)
message(FATAL_ERROR "[${PROJECT_NAME}] - IF97_PRIME_MODULE can only be used on windows host")
endif()
# Check for valid Mathacd Prime Root directory provided by user. If not provided, try to find it on our own.
if( "${IF97_PRIME_ROOT}" STREQUAL "")
message(FATAL_ERROR "[${PROJECT_NAME}] - You must provide the path to MathCAD Prime Root directory using something like -DIF97_PRIME_ROOT=\"C:/Program Files/PTC/Mathcad Prime 3.1\"")
# PTC/Mathcad convention is a directory labeled "C:\Program Files\PTC\Mathad Prime X.X.X.X"
# Find all of these directories on the system and try to set IF97_PRIME_ROOT dynamically
file(GLOB PTC_CONTENTS
LIST_DIRECTORIES true
"C:/Program Files/PTC/Mathcad Prime*"
)
# Add them to a list, sorted by most recent Marhcad Prime release first
set(MATHCAD_SEARCH_PATHS "")
foreach(ITEM ${PTC_CONTENTS})
if(IS_DIRECTORY "${ITEM}")
list(APPEND MATHCAD_SEARCH_PATHS "${ITEM}")
endif()
endforeach()
list(SORT MATHCAD_SEARCH_PATHS COMPARE NATURAL ORDER DESCENDING)
# Now make sure the executable is in one of these directories (newest first)
# Now make sure the executable is in one of these directories (newest first)
unset(MATHCAD_EXE CACHE)
find_program(MATHCAD_EXE
NAMES MathcadPrime.exe
PATHS ${MATHCAD_SEARCH_PATHS}
NO_DEFAULT_PATH)
# Strip off program name, and set IF97_PRIME_ROOT to parent path
#get_filename_comopnent(PARENT_DIR "$MATHCAD_EXE" MATHCAD_ROOT)
if(MATHCAD_EXE)
cmake_path(GET MATHCAD_EXE PARENT_PATH IF97_PRIME_ROOT)
message(STATUS "[${PROJECT_NAME}] - Dynamically Found Mathcad @ \"${IF97_PRIME_ROOT}\"")
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$" MATHCAD_VERSION "${IF97_PRIME_ROOT}")
message(STATUS "[${PROJECT_NAME}] - Linking with Mathcad Prime Library v${MATHCAD_VERSION}\"")
else()
message(STATUS "[${PROJECT_NAME}] - Could not Dynamically Locate Mathcad Prime on this System")
message(FATAL_ERROR "[${PROJECT_NAME}] - You must provide the path to MathCAD Prime Root directory using something like -DIF97_PRIME_ROOT=\"C:/Program Files/PTC/Mathcad Prime 11.0.0.0\"")
endif()
else()
message(STATUS "[${PROJECT_NAME}] - IF97_PRIME_ROOT: ${IF97_PRIME_ROOT}")
# Mathcad Root directory specified. Make sure it's a valid Mathcad Prime installation directory
find_program(MATHCAD_EXE
NAMES MathcadPrime.exe
PATHS ${IF97_PRIME_ROOT})
if(MATHCAD_EXE)
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$" MATHCAD_VERSION "${IF97_PRIME_ROOT}")
message(STATUS "[${PROJECT_NAME}] - Linking with Mathcad Prime Library v${MATHCAD_VERSION}\"")
else()
message(STATUS "[${PROJECT_NAME}] - Could not find Mathcad Prime at ${IF97_PRIME_ROOT}")
message(FATAL_ERROR "[${PROJECT_NAME}] - Check the path to the MathCAD Prime Root directory provided using something like -DIF97_PRIME_ROOT=\"C:/Program Files/PTC/Mathcad Prime 11.0.0.0\"")
endif()
endif()
# Embed Windows VERSIONINFO so IF97.dll's Properties dialog shows
# FileVersion/ProductVersion fields a la CoolProp(#2863). The .rc
# is configured from VERSION above and added to the source
# list only on MSVC and MSYS2(MinGW), where rc.exe is available.
set(IF97_RESOURCE "")
if(MSVC)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/wrapper/Mathcad/dev/IF97.rc.in"
"${CMAKE_CURRENT_BINARY_DIR}/IF97.rc"
@ONLY)
list(APPEND IF97_RESOURCE "${CMAKE_CURRENT_BINARY_DIR}/IF97.rc")
endif()
file(GLOB_RECURSE IF97_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/wrapper/Mathcad/includes/*.h")
include_directories("${IF97_PRIME_ROOT}/Custom Functions" "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/wrapper/Mathcad/includes")
add_library(IF97 SHARED ${IF97_HEADERS} "${CMAKE_CURRENT_SOURCE_DIR}/IF97.h" "${CMAKE_CURRENT_SOURCE_DIR}/wrapper/MathCAD/IF97.cpp")
add_library(IF97 SHARED
${IF97_HEADERS}
"${CMAKE_CURRENT_SOURCE_DIR}/IF97.h"
"${CMAKE_CURRENT_SOURCE_DIR}/wrapper/MathCAD/IF97.cpp"
${IF97_RESOURCE})
target_link_libraries(IF97 "${IF97_PRIME_ROOT}/Custom Functions/mcaduser.lib")
set_target_properties(IF97 PROPERTIES LINK_FLAGS "/ENTRY:\"DllEntryPoint\"")
set_target_properties(IF97 PROPERTIES SUFFIX ".dll" PREFIX "")
Expand Down
20 changes: 0 additions & 20 deletions wrapper/Mathcad/IF97.sln

This file was deleted.

171 changes: 0 additions & 171 deletions wrapper/Mathcad/IF97.vcxproj

This file was deleted.

32 changes: 22 additions & 10 deletions wrapper/Mathcad/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,51 @@ Make the Build for Mathcad Prime (any version above 3.0)

* Go to the top level IF97 directory and make a build directory (something like \build or \buildPrime):

```bash
mkdir buildPrime
cd buildPrime
```

* Build the makefile using CMake (Note: Mathcad Prime is 64-bit):

```cmake
cmake .. -DIF97_PRIME_MODULE=ON
-DIF97_PRIME_ROOT="C:/Program Files/PTC/Mathcad Prime 10.0.0.0"
-G "Visual Studio 17 2022" -A x64
-DCMAKE_VERBOSE_MAKEFILE=ON
-DCMAKE_VERBOSE_MAKEFILE=ON
```

> Insert your version of Mathcad Prime in place of "10.0.0.0".
> Insert your version of Visual Studio for the -G option.
> Note that Mathcad Prime is 64-bit and requires the `-A x64` switch on this command.
> Prior to VS 2017, use something like: `-G "Visual Studio 14 2015 Win64`
- Insert your version of Mathcad Prime in place of "10.0.0.0" (or omit).
- Insert your version of Visual Studio for the `-G` option.
- Note that Mathcad Prime is 64-bit and requires the `-A x64` switch on this command.
- Prior to VS 2017, use something like: `-G "Visual Studio 14 2015 Win64"`.
.
Comment thread
henningjp marked this conversation as resolved.

> **NOTE:**
> Specifying the Mathcad Prime root directory is optional. CMake will attempt to find the most recent version of Mathcad Prime on the system and use that one to link the Mathcad Prime library and header file. If a valid Mathcad Prime installation directory cannot be found, or you want to specify an older version on the system to link to, then supply the ``-DIF97_PRIME_ROOT`` flag as directed above.

Make the Build for Legacy Mathcad 15 (Discontinued by PTC)
----------------------------------------------------------

* Go to the top level IF97 directory and make a build directory (something like \build15):

```bash
mkdir build15
cd build15
```

* Build the makefile using CMake (Note: Mathcad 15 is 32-bit)::

```cmake
cmake .. -DIF97_MATHCAD15_MODULE=ON
-DIF97_MATHCAD15_ROOT="C:/Program Files (x86)/Mathcad/Mathcad 15"
-G "Visual Studio 17 2022" -A Win32
-DCMAKE_VERBOSE_MAKEFILE=ON

> Insert your version of Visual Studio for the -G option.
> Legacy Mathcad was 32-bit and requires a 32-bit add-in DLL.
> Prior to VS2017, use something like `-G "Visual Studio 14 2015` as 32-bit was the default.
```

- Insert your version of Visual Studio for the -G option.
- Legacy Mathcad was 32-bit and requires a 32-bit add-in DLL.
- Prior to VS2017, use something like `-G "Visual Studio 14 2015` as 32-bit was the default.
Comment on lines +99 to +101
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix inconsistent list indentation.

Lines 100-101 use 4-space indentation where 1-space is expected, triggering markdownlint MD005.

📐 Proposed fix
-         
-	- Insert your version of Visual Studio for the -G option.  
-    - Legacy Mathcad was 32-bit and requires a 32-bit add-in DLL.  
-    - Prior to VS2017, use something like `-G "Visual Studio 14 2015` as 32-bit was the default.
+
+ - Insert your version of Visual Studio for the -G option.  
+ - Legacy Mathcad was 32-bit and requires a 32-bit add-in DLL.  
+ - Prior to VS2017, use something like `-G "Visual Studio 14 2015` as 32-bit was the default.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Insert your version of Visual Studio for the -G option.
- Legacy Mathcad was 32-bit and requires a 32-bit add-in DLL.
- Prior to VS2017, use something like `-G "Visual Studio 14 2015` as 32-bit was the default.
- Insert your version of Visual Studio for the -G option.
- Legacy Mathcad was 32-bit and requires a 32-bit add-in DLL.
- Prior to VS2017, use something like `-G "Visual Studio 14 2015` as 32-bit was the default.
🧰 Tools
🪛 LanguageTool

[style] ~101-~101: ‘Prior to’ might be wordy. Consider a shorter alternative.
Context: ...d requires a 32-bit add-in DLL. - Prior to VS2017, use something like `-G "Visual ...

(EN_WORDINESS_PREMIUM_PRIOR_TO)

🪛 markdownlint-cli2 (0.22.1)

[warning] 100-100: Inconsistent indentation for list items at the same level
Expected: 1; Actual: 4

(MD005, list-indent)


[warning] 101-101: Inconsistent indentation for list items at the same level
Expected: 1; Actual: 4

(MD005, list-indent)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@wrapper/Mathcad/README.md` around lines 99 - 101, The markdown list items
"Legacy Mathcad was 32-bit and requires a 32-bit add-in DLL." and "Prior to
VS2017, use something like `-G "Visual Studio 14 2015` as 32-bit was the
default." have 4-space indentation causing MD005; change their indentation to a
single space (align them with the other list items) so each line begins with one
space then the hyphen, ensuring consistent list indentation in README.md.


Build the Project
-----------------
Expand Down Expand Up @@ -131,4 +143,4 @@ Compiler Flags
==============
The Mathcad wrapper code uses the ``REGION3_ITERATE`` flag to provide more accurate (but slightly slower) calculation of density in Region 3 (mostly super-critical), but does **_not_** use the ``IAPWS_UNITS`` flag by default, leaving all input/output values in SI units.

The `IAPWS_UNITS` flag can be set (uncommented) in the top of the IF97.cpp file to input and output IAPWS units (Pressures in MPa and energy in kJ) for easy comparison with IAPWS release documents.
The `IAPWS_UNITS` flag can be set (uncommented) in the top of the IF97.cpp file to input and output IAPWS units (Pressures in MPa and energy in kJ) for easy comparison with IAPWS release documents.
Loading
Loading