From 31e69e30a9391a6818ef13d298627db318a840c4 Mon Sep 17 00:00:00 2001 From: Dan Macumber Date: Tue, 26 Mar 2024 11:37:14 -0600 Subject: [PATCH 1/3] Install openstudio to bin directory so it can be found relative to lib, fixes #695 --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ccb1095c..24d15fb03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -749,10 +749,10 @@ install(DIRECTORY "${openstudio_ROOT_DIR}/Python" DESTINATION "." COMPONENT "Pyt # TODO: at 3.5.0, the lib/ directory on UNIX (only UNIX) contains the libopenstudiolib.so, but also the librubyengine.so, libpythonengine.so # install(DIRECTORY "${openstudio_ROOT_DIR}/lib" DESTINATION "." COMPONENT "OpenStudioApp" USE_SOURCE_PERMISSIONS) -if(NOT APPLE) - # On Mac, in openstudio_app/CMakeLists.txt we've already copied the CLI to the OpenStudio.app/Contents/MacOS - install(IMPORTED_RUNTIME_ARTIFACTS openstudio::openstudio DESTINATION bin COMPONENT "CLI") -endif() +# On Mac, in openstudio_app/CMakeLists.txt we've already copied the CLI to the OpenStudio.app/Contents/MacOS +# However, it is still needed in the bin directory so it can be found relative to the files in lib, this occurs +# when a measure tries to use getOpenStudioCLI, see #695 +install(IMPORTED_RUNTIME_ARTIFACTS openstudio::openstudio DESTINATION bin COMPONENT "CLI") install(IMPORTED_RUNTIME_ARTIFACTS openstudio::openstudiolib DESTINATION ${LIB_DESTINATION_DIR} COMPONENT "CLI") install(IMPORTED_RUNTIME_ARTIFACTS openstudio::rubyengine DESTINATION ${LIB_DESTINATION_DIR} COMPONENT "CLI") install(IMPORTED_RUNTIME_ARTIFACTS openstudio::pythonengine DESTINATION ${LIB_DESTINATION_DIR} COMPONENT "CLI") From db51756e94e5e00055a4047af0b2e558c38d4dd8 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Wed, 27 Mar 2024 09:58:55 +0100 Subject: [PATCH 2/3] Install a symlink instead of copying the cli --- CMakeLists.txt | 11 +++++++---- src/openstudio_app/CMakeLists.txt | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24d15fb03..19f163aa4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -749,10 +749,13 @@ install(DIRECTORY "${openstudio_ROOT_DIR}/Python" DESTINATION "." COMPONENT "Pyt # TODO: at 3.5.0, the lib/ directory on UNIX (only UNIX) contains the libopenstudiolib.so, but also the librubyengine.so, libpythonengine.so # install(DIRECTORY "${openstudio_ROOT_DIR}/lib" DESTINATION "." COMPONENT "OpenStudioApp" USE_SOURCE_PERMISSIONS) -# On Mac, in openstudio_app/CMakeLists.txt we've already copied the CLI to the OpenStudio.app/Contents/MacOS -# However, it is still needed in the bin directory so it can be found relative to the files in lib, this occurs -# when a measure tries to use getOpenStudioCLI, see #695 -install(IMPORTED_RUNTIME_ARTIFACTS openstudio::openstudio DESTINATION bin COMPONENT "CLI") +if(NOT APPLE) + # On Mac, we want to have openstudio CLI next to the OpenStudioApp in ./OpenStudio.app/Contents/MacOS + # But we still need it in the ./bin directory so it can be found relative to the files in ./lib, this occurs when a measure tries to use getOpenStudioCLI, see #695 + # In openstudio_app/CMakeLists.txt we've already copied the CLI to the OpenStudio.app/Contents/MacOS, and we install a symlink to ./bin as well + # TODO: the link order is the reverse of the lib ones (where we create a symlink **in the bundle** that points to the ./lib contents) + install(IMPORTED_RUNTIME_ARTIFACTS openstudio::openstudio DESTINATION bin COMPONENT "CLI") +endif() install(IMPORTED_RUNTIME_ARTIFACTS openstudio::openstudiolib DESTINATION ${LIB_DESTINATION_DIR} COMPONENT "CLI") install(IMPORTED_RUNTIME_ARTIFACTS openstudio::rubyengine DESTINATION ${LIB_DESTINATION_DIR} COMPONENT "CLI") install(IMPORTED_RUNTIME_ARTIFACTS openstudio::pythonengine DESTINATION ${LIB_DESTINATION_DIR} COMPONENT "CLI") diff --git a/src/openstudio_app/CMakeLists.txt b/src/openstudio_app/CMakeLists.txt index 6ad1cb425..f3c270819 100644 --- a/src/openstudio_app/CMakeLists.txt +++ b/src/openstudio_app/CMakeLists.txt @@ -459,6 +459,10 @@ if( APPLE ) "../../../lib/$" "${CMAKE_INSTALL_PREFIX}/OpenStudioApp.app/Contents/Frameworks/$" + COMMAND "${CMAKE_COMMAND}" -E create_symlink + "../OpenStudioApp.app/Contents/MacOS/$" + "${CMAKE_INSTALL_PREFIX}/bin/$" + COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL ANY ) From ce0ae41d0ffb2e941e7d30e2b972e6de165e3feb Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Wed, 27 Mar 2024 14:36:20 +0100 Subject: [PATCH 3/3] bin doesn't exist when this is run. Try to mkdir --- src/openstudio_app/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/openstudio_app/CMakeLists.txt b/src/openstudio_app/CMakeLists.txt index f3c270819..c576284db 100644 --- a/src/openstudio_app/CMakeLists.txt +++ b/src/openstudio_app/CMakeLists.txt @@ -459,6 +459,7 @@ if( APPLE ) "../../../lib/$" "${CMAKE_INSTALL_PREFIX}/OpenStudioApp.app/Contents/Frameworks/$" + COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_INSTALL_PREFIX}/bin" COMMAND "${CMAKE_COMMAND}" -E create_symlink "../OpenStudioApp.app/Contents/MacOS/$" "${CMAKE_INSTALL_PREFIX}/bin/$"