From 652e396bc027019f08daab458cd339809d71aaa9 Mon Sep 17 00:00:00 2001 From: sgpearse Date: Thu, 13 Jun 2024 11:35:40 -0600 Subject: [PATCH 1/4] test apple build with configure_apple_deployment_target --- .circleci/config.yml | 4 +-- CMakeLists.txt | 48 +++++++++++++------------ buildutils/ConfigurationFunctions.cmake | 23 ++++++++++++ 3 files changed, 50 insertions(+), 25 deletions(-) create mode 100644 buildutils/ConfigurationFunctions.cmake diff --git a/.circleci/config.yml b/.circleci/config.yml index 76eaded42..5562d4e5d 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -922,8 +922,8 @@ workflows: #- build_python_api_ubuntu #- build_python_api_osx #- build_win10_installer - #- build_macOS_installers - - build_linux_installer + - build_macOS_installers + #- build_linux_installer #- build_suse_installer #- build_ubuntu20_libs #- build_macOSx86_libs diff --git a/CMakeLists.txt b/CMakeLists.txt index ac0553551..3f82cae2c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,29 +20,31 @@ if(NOT CMAKE_BUILD_TYPE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "DEBUG" "RELEASE" "RELWITHDEBINFO") endif() -if(APPLE) - if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") - # Check if the target architecture is arm64 - include(CheckCXXSourceRuns) - set(CMAKE_REQUIRED_FLAGS "-arch arm64") - set(CHECK_ARM64_SOURCE_CODE "int main() { return 0; }") - check_cxx_source_runs("${CHECK_ARM64_SOURCE_CODE}" IS_ARM64) - if(IS_ARM64) - set(CMAKE_OSX_ARCHITECTURES arm64) - else() - set(CMAKE_OSX_ARCHITECTURES x86_64) - endif() - endif() - - if (CMAKE_OSX_ARCHITECTURES MATCHES "arm64") - message("Building on macOS M1 architecture (arm64)") - set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0" CACHE STRING "Minimum OS X deployment version" FORCE) - else() - message("Building on macOS x86 architecture") - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE) - set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "macOS build architecture" FORCE) - endif() -endif() +# Sets variable CMAKE_OSX_DEPLOYMENT_TARGET, and CMAKE_OSX_ARCHITECTURES if building on x86 +configure_apple_deployment_target() +#if(APPLE) +# if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") +# # Check if the target architecture is arm64 +# include(CheckCXXSourceRuns) +# set(CMAKE_REQUIRED_FLAGS "-arch arm64") +# set(CHECK_ARM64_SOURCE_CODE "int main() { return 0; }") +# check_cxx_source_runs("${CHECK_ARM64_SOURCE_CODE}" IS_ARM64) +# if(IS_ARM64) +# set(CMAKE_OSX_ARCHITECTURES arm64) +# else() +# set(CMAKE_OSX_ARCHITECTURES x86_64) +# endif() +# endif() +# +# if (CMAKE_OSX_ARCHITECTURES MATCHES "arm64") +# message("Building on macOS M1 architecture (arm64)") +# set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0" CACHE STRING "Minimum OS X deployment version" FORCE) +# else() +# message("Building on macOS x86 architecture") +# set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE) +# set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "macOS build architecture" FORCE) +# endif() +#endif() set (VERSION_MAJOR 3) set (VERSION_MINOR 9) diff --git a/buildutils/ConfigurationFunctions.cmake b/buildutils/ConfigurationFunctions.cmake new file mode 100644 index 000000000..3c2629ac7 --- /dev/null +++ b/buildutils/ConfigurationFunctions.cmake @@ -0,0 +1,23 @@ +function(configure_apple_deployment_target) + if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") + # Check if the target architecture is arm64 + include(CheckCXXSourceRuns) + set(CMAKE_REQUIRED_FLAGS "-arch arm64") + set(CHECK_ARM64_SOURCE_CODE "int main() { return 0; }") + check_cxx_source_runs("${CHECK_ARM64_SOURCE_CODE}" IS_ARM64) + if(IS_ARM64) + set(CMAKE_OSX_ARCHITECTURES arm64 PARENT_SCOPE) + else() + set(CMAKE_OSX_ARCHITECTURES x86_64 PARENT_SCOPE) + endif() + endif() + + if (CMAKE_OSX_ARCHITECTURES MATCHES "arm64") + message("Building on macOS M1 architecture (arm64)") + set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0" CACHE STRING "Minimum OS X deployment version" FORCE PARENT_SCOPE) + else() + message("Building on macOS x86 architecture") + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE PARENT_SCOPE) + set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "macOS build architecture" FORCE PARENT_SCOPE) + endif() +endfunction() From c65f1d80363fba89f069cd4578afb405ef14f2e2 Mon Sep 17 00:00:00 2001 From: sgpearse Date: Thu, 13 Jun 2024 15:48:30 -0600 Subject: [PATCH 2/4] test --- CMakeLists.txt | 25 ++----------------------- buildutils/ConfigurationFunctions.cmake | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f82cae2c..e77147069 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ project (VAPOR3) include (buildutils/UtilityFunctions.cmake) include (buildutils/GetGitRevisionDescription.cmake) include (buildutils/OpenMPInstaller.cmake) +include (buildutils/ConfigurationFunctions.cmake) set (CMAKE_CXX_STANDARD 11) set (CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -22,35 +23,13 @@ endif() # Sets variable CMAKE_OSX_DEPLOYMENT_TARGET, and CMAKE_OSX_ARCHITECTURES if building on x86 configure_apple_deployment_target() -#if(APPLE) -# if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") -# # Check if the target architecture is arm64 -# include(CheckCXXSourceRuns) -# set(CMAKE_REQUIRED_FLAGS "-arch arm64") -# set(CHECK_ARM64_SOURCE_CODE "int main() { return 0; }") -# check_cxx_source_runs("${CHECK_ARM64_SOURCE_CODE}" IS_ARM64) -# if(IS_ARM64) -# set(CMAKE_OSX_ARCHITECTURES arm64) -# else() -# set(CMAKE_OSX_ARCHITECTURES x86_64) -# endif() -# endif() -# -# if (CMAKE_OSX_ARCHITECTURES MATCHES "arm64") -# message("Building on macOS M1 architecture (arm64)") -# set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0" CACHE STRING "Minimum OS X deployment version" FORCE) -# else() -# message("Building on macOS x86 architecture") -# set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE) -# set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "macOS build architecture" FORCE) -# endif() -#endif() set (VERSION_MAJOR 3) set (VERSION_MINOR 9) set (VERSION_MICRO 3) set (VERSION_RC ) message("CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}") + if (CMAKE_BUILD_TYPE STREQUAL "Release") get_git_head_revision (GIT_REFSPEC VERSION_COMMIT) message("VERSION_COMMIT ${VERSION_COMMIT}") diff --git a/buildutils/ConfigurationFunctions.cmake b/buildutils/ConfigurationFunctions.cmake index 3c2629ac7..89a5e8a61 100644 --- a/buildutils/ConfigurationFunctions.cmake +++ b/buildutils/ConfigurationFunctions.cmake @@ -21,3 +21,24 @@ function(configure_apple_deployment_target) set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "macOS build architecture" FORCE PARENT_SCOPE) endif() endfunction() + +function(tag_commit_hash) + if (CMAKE_BUILD_TYPE STREQUAL "Release") + get_git_head_revision (GIT_REFSPEC VERSION_COMMIT) + message("VERSION_COMMIT ${VERSION_COMMIT}") + execute_process ( + COMMAND git rev-parse --short ${VERSION_COMMIT} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE VERSION_COMMIT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + message("VERSION_COMMIT2 ${VERSION_COMMIT}") + endif () + string (TIMESTAMP VERSION_DATE UTC) + if (VERSION_RC) + set (VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}.${VERSION_RC}) + else () + set (VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}) + endif () + set (VERSION_STRING_FULL ${VERSION_STRING}.${VERSION_COMMIT} PARENT_SCOPE) +endfunction() From cd7d6b3bfceff2564da335b0e25be99f0694f55f Mon Sep 17 00:00:00 2001 From: sgpearse Date: Tue, 18 Jun 2024 10:09:07 -0600 Subject: [PATCH 3/4] break out some functions --- CMakeLists.txt | 167 +++++------------------- buildutils/ConfigurationFunctions.cmake | 122 +++++++++++++++-- 2 files changed, 149 insertions(+), 140 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e77147069..68de0b85b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,48 +30,11 @@ set (VERSION_MICRO 3) set (VERSION_RC ) message("CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}") -if (CMAKE_BUILD_TYPE STREQUAL "Release") - get_git_head_revision (GIT_REFSPEC VERSION_COMMIT) - message("VERSION_COMMIT ${VERSION_COMMIT}") - execute_process ( - COMMAND git rev-parse --short ${VERSION_COMMIT} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE VERSION_COMMIT - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - message("VERSION_COMMIT2 ${VERSION_COMMIT}") -endif () -string (TIMESTAMP VERSION_DATE UTC) -if (VERSION_RC) - set (VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}.${VERSION_RC}) -else () - set (VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}) -endif () -set (VERSION_STRING_FULL ${VERSION_STRING}.${VERSION_COMMIT}) - -if (APPLE) - add_definitions (-DDarwin) -elseif (WIN32) - add_definitions (-DWIN32 -DNOMINMAX) - add_definitions (-DGLAD_API_CALL_EXPORT) -endif() - -# compiler warning flags -if (NOT WIN32) - SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -Wno-overloaded-virtual -Wno-parentheses") - SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-sign-compare") -else () - # Enable multithread compiling on Visual Studio - # This feature is glitchy so you may need to re-run - SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") - SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") -endif() +tag_commit_hash() +message("VERSION_STRING_FULL=${VERSION_STRING_FULL}") -if (CMAKE_GENERATOR STREQUAL "Xcode") - set (DEFAULT_BUILD_UTILITIES OFF) -else () - set (DEFAULT_BUILD_UTILITIES ON) -endif () +set_compiler_flags() +message("CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") option (BUILD_VDC "Build VDC library and utilities" ON) option (BUILD_GUI "Build Vapor GUI" ON) @@ -137,7 +100,7 @@ if (CONDA_BUILD) set (MAP_IMAGES_PATH $ENV{MAP_IMAGES_PATH}) endif() else() - message("THIRD_PARTY_DIR = ${THIRD_PARTY_DIR}") + message("THIRD_PARTY_DIR = ${THIRD_PARTY_DIR}") include_directories (SYSTEM ${THIRD_PARTY_INC_DIR}) include_directories (SYSTEM ${THIRD_PARTY_INC_DIR}/freetype2) link_directories (${THIRD_PARTY_LIB_DIR}) @@ -176,7 +139,7 @@ message("Library FREETYPE = ${FREETYPE}") message("Library GEOTIFF = ${GEOTIFF}") message("Library JPEG = ${JPEG}") message("Library HDF5_LIB = ${HDF5_LIB}") -message("Library EXPAT = ${EXPAT}") +message("Library EXPAT = ${EXPAT}") # find_package(Python) # Output @@ -188,58 +151,6 @@ message("Library EXPAT = ${EXPAT}") # ${Python_NumPy_INCLUDE_DIRS} # https://cmake.org/cmake/help/v3.12/module/FindPython.html -function(FIND_BUNDLED_PYTHON) - # FindPython supports Python_ROOT_DIR however vapor's bundled python distribution - # does not conform to its requirements so this manually configures the results - message("Using bundled python") - set(Python_VERSION "${PYTHONVERSION}") - set(Python_NumPy_INCLUDE_DIRS "${NUMPY_INCLUDE_DIR}") - unset(Python_LIBRARIES) # This is required for find_library to work in certain cases - find_library( - Python_LIBRARIES - NAMES python${PYTHONVERSION} python${PYTHONVERSION}m - PATHS ${THIRD_PARTY_LIB_DIR} ${PYTHONPATH} - NO_DEFAULT_PATH - ) - if (WIN32) - set(Python_SITELIB "${PYTHONPATH}/Lib/site-packages") - set(Python_INCLUDE_DIRS "${THIRD_PARTY_DIR}/Python${PYTHONVERSION}/include") - else() - set(Python_SITELIB "${PYTHONPATH}/site-packages") - if (NOT DEFINED Python_INCLUDE_DIRS) - set(Python_INCLUDE_DIRS "${THIRD_PARTY_INC_DIR}/python${PYTHONVERSION}") - endif() - endif() - - set(Python_VERSION "${Python_VERSION}" PARENT_SCOPE) - set(Python_LIBRARIES "${Python_LIBRARIES}" PARENT_SCOPE) - set(Python_INCLUDE_DIRS "${Python_INCLUDE_DIRS}" PARENT_SCOPE) - set(Python_SITELIB "${Python_SITELIB}" PARENT_SCOPE) - set(Python_NumPy_VERSION "UNUSED IN BUNDLED PYTHON" PARENT_SCOPE) - set(Python_NumPy_INCLUDE_DIRS "${Python_NumPy_INCLUDE_DIRS}" PARENT_SCOPE) -endfunction() - -function(DUMP_FOUND_PYTHON) - set(PATHS "") - list(APPEND PATHS - Python_LIBRARIES - Python_INCLUDE_DIRS - Python_SITELIB - Python_NumPy_INCLUDE_DIRS - ) - message("Python Found ${ARGV0}") - message("\tPython_VERSION = '${Python_VERSION}'") - message("\tPython_NumPy_VERSION = '${Python_NumPy_VERSION}'") - foreach(V ${PATHS}) - if (EXISTS "${${V}}") - set(VE "OK") - else() - set(VE "**NOT FOUND**") - endif() - message("\t${V} = '${${V}}' ${VE}") - endforeach() -endfunction() - # TODO # - Replace PYTHONVERSION with Python_VERSION @@ -254,12 +165,6 @@ dump_found_python() include_directories ("${Python_INCLUDE_DIRS}") include_directories ("${Python_NumPy_INCLUDE_DIRS}") - -# if (BUILD_GUI OR BUILD_PYTHON) -# find_package (OpenGL REQUIRED) -# include_directories (${OPENGL_INCLUDE_DIRS}) -# endif () - if (WIN32) find_library(ASSIMP assimp-vc140-mt) find_library(TIFF libtiff) @@ -276,36 +181,36 @@ if (WIN32) set (INSTALL_SHARE_DIR share) set (INSTALL_INCLUDE_DIR include/vapor) elseif (APPLE) - - # if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - if (DIST_INSTALLER AND NOT BUILD_PYTHON) - set (CMAKE_INSTALL_PREFIX /Applications) - set (INSTALL_BIN_DIR ./vapor.app/Contents/MacOS) - set (INSTALL_SHARE_DIR ./vapor.app/Contents/share) - #set (INSTALL_LIB_DIR ./vapor.app/Contents/lib) - set (INSTALL_LIB_DIR ./vapor.app/Contents/Frameworks) - set (INSTALL_INCLUDE_DIR ./vapor.app/Contents/include/vapor) - else () - set (INSTALL_BIN_DIR bin) - set (INSTALL_LIB_DIR lib) - set (INSTALL_SHARE_DIR share) - set (INSTALL_INCLUDE_DIR include/vapor) - endif () - - if (BUILD_PYTHON) - set (CMAKE_INSTALL_RPATH "@loader_path") - else () - #set (CMAKE_INSTALL_RPATH "@executable_path/../lib") - set (CMAKE_INSTALL_RPATH "@executable_path/../Frameworks") - endif () - - if (DIST_INSTALLER AND USE_OMP) - message (WARNING "The build mode is set to distributable installer with OpenMP enabled and will not run from source") - set (INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") - set (CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) - set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - set (CMAKE_SKIP_BUILD_RPATH FALSE) - endif() + configure_apple_compilation() + ## if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + #if (DIST_INSTALLER AND NOT BUILD_PYTHON) + # set (CMAKE_INSTALL_PREFIX /Applications) + # set (INSTALL_BIN_DIR ./vapor.app/Contents/MacOS) + # set (INSTALL_SHARE_DIR ./vapor.app/Contents/share) + # #set (INSTALL_LIB_DIR ./vapor.app/Contents/lib) + # set (INSTALL_LIB_DIR ./vapor.app/Contents/Frameworks) + # set (INSTALL_INCLUDE_DIR ./vapor.app/Contents/include/vapor) + #else () + # set (INSTALL_BIN_DIR bin) + # set (INSTALL_LIB_DIR lib) + # set (INSTALL_SHARE_DIR share) + # set (INSTALL_INCLUDE_DIR include/vapor) + #endif () + + #if (BUILD_PYTHON) + # set (CMAKE_INSTALL_RPATH "@loader_path") + #else () + # #set (CMAKE_INSTALL_RPATH "@executable_path/../lib") + # set (CMAKE_INSTALL_RPATH "@executable_path/../Frameworks") + #endif () + + #if (DIST_INSTALLER AND USE_OMP) + # message (WARNING "The build mode is set to distributable installer with OpenMP enabled and will not run from source") + # set (INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") + # set (CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) + # set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) + # set (CMAKE_SKIP_BUILD_RPATH FALSE) + #endif() else () if (DIST_INSTALLER) set (INSTALL_BIN_DIR lib) diff --git a/buildutils/ConfigurationFunctions.cmake b/buildutils/ConfigurationFunctions.cmake index 89a5e8a61..98c3d9fe3 100644 --- a/buildutils/ConfigurationFunctions.cmake +++ b/buildutils/ConfigurationFunctions.cmake @@ -6,34 +6,33 @@ function(configure_apple_deployment_target) set(CHECK_ARM64_SOURCE_CODE "int main() { return 0; }") check_cxx_source_runs("${CHECK_ARM64_SOURCE_CODE}" IS_ARM64) if(IS_ARM64) - set(CMAKE_OSX_ARCHITECTURES arm64 PARENT_SCOPE) + set(CMAKE_OSX_ARCHITECTURES arm64) else() - set(CMAKE_OSX_ARCHITECTURES x86_64 PARENT_SCOPE) + set(CMAKE_OSX_ARCHITECTURES x86_64) endif() endif() + # No need for PARENT_SCOPE here, since we are caching the variable and therefore making it global if (CMAKE_OSX_ARCHITECTURES MATCHES "arm64") message("Building on macOS M1 architecture (arm64)") - set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0" CACHE STRING "Minimum OS X deployment version" FORCE PARENT_SCOPE) + set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0" CACHE STRING "Minimum OS X deployment version" FORCE) else() message("Building on macOS x86 architecture") - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE PARENT_SCOPE) - set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "macOS build architecture" FORCE PARENT_SCOPE) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE) + set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "macOS build architecture" FORCE) endif() endfunction() function(tag_commit_hash) - if (CMAKE_BUILD_TYPE STREQUAL "Release") + #if (CMAKE_BUILD_TYPE STREQUAL "Release") get_git_head_revision (GIT_REFSPEC VERSION_COMMIT) - message("VERSION_COMMIT ${VERSION_COMMIT}") execute_process ( COMMAND git rev-parse --short ${VERSION_COMMIT} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE VERSION_COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE ) - message("VERSION_COMMIT2 ${VERSION_COMMIT}") - endif () + #endif () string (TIMESTAMP VERSION_DATE UTC) if (VERSION_RC) set (VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}.${VERSION_RC}) @@ -42,3 +41,108 @@ function(tag_commit_hash) endif () set (VERSION_STRING_FULL ${VERSION_STRING}.${VERSION_COMMIT} PARENT_SCOPE) endfunction() + +function(set_compiler_flags) + if (APPLE) + add_definitions (-DDarwin) + elseif (WIN32) + add_definitions (-DWIN32 -DNOMINMAX) + add_definitions (-DGLAD_API_CALL_EXPORT) + endif() + + # compiler warning flags + if (NOT WIN32) + SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-sign-compare -Wno-overloaded-virtual -Wno-parentheses" PARENT_SCOPE) + SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-sign-compare" PARENT_SCOPE) + else () + # Enable multithread compiling on Visual Studio + # This feature is glitchy so you may need to re-run + SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP" PARENT_SCOPE) + SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP" PARENT_SCOPE) + endif() +endFunction() + +function(find_bundled_python) + # FindPython supports Python_ROOT_DIR however vapor's bundled python distribution + # does not conform to its requirements so this manually configures the results + message("Using bundled python ${PYTHONVERSION}...") + set(Python_VERSION "${PYTHONVERSION}") + set(Python_NumPy_INCLUDE_DIRS "${NUMPY_INCLUDE_DIR}") + unset(Python_LIBRARIES) # This is required for find_library to work in certain cases + find_library( + Python_LIBRARIES + NAMES python${PYTHONVERSION} python${PYTHONVERSION}m + PATHS ${THIRD_PARTY_LIB_DIR} ${PYTHONPATH} + NO_DEFAULT_PATH + ) + if (WIN32) + set(Python_SITELIB "${PYTHONPATH}/Lib/site-packages") + set(Python_INCLUDE_DIRS "${THIRD_PARTY_DIR}/Python${PYTHONVERSION}/include") + else() + set(Python_SITELIB "${PYTHONPATH}/site-packages" PARENT_SCOPE) + if (NOT DEFINED Python_INCLUDE_DIRS) + set(Python_INCLUDE_DIRS "${THIRD_PARTY_INC_DIR}/python${PYTHONVERSION}") + message("Python_INCLUDE_DIRS ${THIRD_PARTY_INC_DIR}/python${PYTHONVERSION}") + endif() + endif() + + set(Python_VERSION "${Python_VERSION}" PARENT_SCOPE) + set(Python_LIBRARIES "${Python_LIBRARIES}" PARENT_SCOPE) + set(Python_INCLUDE_DIRS "${Python_INCLUDE_DIRS}" PARENT_SCOPE) + set(Python_SITELIB "${Python_SITELIB}" PARENT_SCOPE) + set(Python_NumPy_VERSION "UNUSED IN BUNDLED PYTHON" PARENT_SCOPE) + set(Python_NumPy_INCLUDE_DIRS "${Python_NumPy_INCLUDE_DIRS}" PARENT_SCOPE) +endfunction() + +function(dump_found_python) + set(PATHS "") + list(APPEND PATHS + Python_LIBRARIES + Python_INCLUDE_DIRS + Python_SITELIB + Python_NumPy_INCLUDE_DIRS + ) + message("Python Found ${ARGV0}") + message("\tPython_VERSION = '${Python_VERSION}'") + message("\tPython_NumPy_VERSION = '${Python_NumPy_VERSION}'") + foreach(V ${PATHS}) + if (EXISTS "${${V}}") + set(VE "OK") + else() + set(VE "**NOT FOUND**") + endif() + message("\t${V} = '${${V}}' ${VE}") + endforeach() +endfunction() + +function(configure_apple_compilation) + # if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + if (DIST_INSTALLER AND NOT BUILD_PYTHON) + set (CMAKE_INSTALL_PREFIX /Applications PARENT_SCOPE) + set (INSTALL_BIN_DIR ./vapor.app/Contents/MacOS PARENT_SCOPE) + set (INSTALL_SHARE_DIR ./vapor.app/Contents/share PARENT_SCOPE) + #set (INSTALL_LIB_DIR ./vapor.app/Contents/lib) + set (INSTALL_LIB_DIR ./vapor.app/Contents/Frameworks PARENT_SCOPE) + set (INSTALL_INCLUDE_DIR ./vapor.app/Contents/include/vapor PARENT_SCOPE) + else () + set (INSTALL_BIN_DIR bin PARENT_SCOPE) + set (INSTALL_LIB_DIR lib PARENT_SCOPE) + set (INSTALL_SHARE_DIR share PARENT_SCOPE) + set (INSTALL_INCLUDE_DIR include/vapor PARENT_SCOPE) + endif () + + if (BUILD_PYTHON) + set (CMAKE_INSTALL_RPATH "@loader_path" PARENT_SCOPE) + else () + #set (CMAKE_INSTALL_RPATH "@executable_path/../lib") + set (CMAKE_INSTALL_RPATH "@executable_path/../Frameworks" PARENT_SCOPE) + endif () + + if (DIST_INSTALLER AND USE_OMP) + message (WARNING "The build mode is set to distributable installer with OpenMP enabled and will not run from source") + set (INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" PARENT_SCOPE) + set (CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE PARENT_SCOPE) + set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE PARENT_SCOPE) + set (CMAKE_SKIP_BUILD_RPATH FALSE PARENT_SCOPE) + endif() +endfunction() From 2cefa77c4e6f99c39bdd4219f2ac1f2ebaad2ca1 Mon Sep 17 00:00:00 2001 From: sgpearse Date: Thu, 20 Jun 2024 12:50:35 -0600 Subject: [PATCH 4/4] updates --- .circleci/config.yml | 33 +++++++----------- CMakeLists.txt | 32 ------------------ apps/pythonapi/vapor/dataset.py | 28 +++++++++++++-- apps/pythonapi/vapor/transferfunction.py | 2 ++ apps/vaporgui/ParticleEventRouter.cpp | 1 + buildutils/ConfigurationFunctions.cmake | 11 +++--- include/vapor/ParticleParams.h | 1 + include/vapor/ParticleRenderer.h | 2 ++ lib/params/ParticleParams.cpp | 1 + lib/render/ParticleRenderer.cpp | 43 +++++++++++++++++------- 10 files changed, 82 insertions(+), 72 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5562d4e5d..91c7534bb 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,8 +30,10 @@ commands: default: true fileName: type: string + default: "" driveID: type: string + default: "" sudo: type: string default: "" @@ -233,7 +235,7 @@ jobs: # clang # If we run selfupdate on every run, we will update clang on minor revisions, taking 1+ hours to build # Therefore, skip selfupdate until we know we want a newer version of clang - (sudo yes || true) | sudo /opt/local/bin/port install clang-17 +universal + #(sudo yes || true) | sudo /opt/local/bin/port install clang-17 +universal sudo /opt/local/bin/port select --set clang mp-clang-17 /opt/local/bin/clang++ -v > clangVersion.txt @@ -244,35 +246,26 @@ jobs: paths: - /opt/local - #- get_libraries: - # fileName: 2023-Sept-M1.tar.xz - # driveID: *macOSM1LibID - # sudo: sudo - - get_libraries: - fileName: 2023-Jun-macOSx86.tar.xz - driveID: *macOSx86LibID + fileName: *macArm64libAWS sudo: sudo - build_vapor: - #beforeCompile: export PATH=/opt/local/bin:$PATH; sudo port select --set clang mp-clang-17 - beforeCompile: export PATH=/opt/local/bin:$PATH; softwareupdate --install-rosetta --agree-to-license; sudo /opt/local/bin/port select --set clang mp-clang-17 + beforeCompile: export PATH=/opt/local/bin:$PATH; sudo port select --set clang mp-clang-17 compileArgs: | -DCPACK_BINARY_DRAGNDROP=ON \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_C_COMPILER=clang \ - -DCMAKE_OSX_ARCHITECTURES=x86_64 \ -DBUILD_OSP=OFF \ moveToCommand: ${f/Darwin/DarwinM1} - #- run: - # name: remove old libraries - # command: sudo rm -rf /usr/local/VAPOR-Deps + - run: + name: remove old libraries + command: sudo rm -rf /usr/local/VAPOR-Deps - #- get_libraries: - # fileName: 2023-Jun-macOSx86.tar.xz - # driveID: *macOSx86LibID - # sudo: sudo + - get_libraries: + fileName: &macx86libAWS + sudo: sudo - build_vapor: beforeCompile: export PATH=/opt/local/bin:$PATH; softwareupdate --install-rosetta --agree-to-license; sudo port select --set clang mp-clang-17 @@ -922,8 +915,8 @@ workflows: #- build_python_api_ubuntu #- build_python_api_osx #- build_win10_installer - - build_macOS_installers - #- build_linux_installer + #- build_macOS_installers + - build_linux_installer #- build_suse_installer #- build_ubuntu20_libs #- build_macOSx86_libs diff --git a/CMakeLists.txt b/CMakeLists.txt index 68de0b85b..8e5abf23a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,35 +182,6 @@ if (WIN32) set (INSTALL_INCLUDE_DIR include/vapor) elseif (APPLE) configure_apple_compilation() - ## if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - #if (DIST_INSTALLER AND NOT BUILD_PYTHON) - # set (CMAKE_INSTALL_PREFIX /Applications) - # set (INSTALL_BIN_DIR ./vapor.app/Contents/MacOS) - # set (INSTALL_SHARE_DIR ./vapor.app/Contents/share) - # #set (INSTALL_LIB_DIR ./vapor.app/Contents/lib) - # set (INSTALL_LIB_DIR ./vapor.app/Contents/Frameworks) - # set (INSTALL_INCLUDE_DIR ./vapor.app/Contents/include/vapor) - #else () - # set (INSTALL_BIN_DIR bin) - # set (INSTALL_LIB_DIR lib) - # set (INSTALL_SHARE_DIR share) - # set (INSTALL_INCLUDE_DIR include/vapor) - #endif () - - #if (BUILD_PYTHON) - # set (CMAKE_INSTALL_RPATH "@loader_path") - #else () - # #set (CMAKE_INSTALL_RPATH "@executable_path/../lib") - # set (CMAKE_INSTALL_RPATH "@executable_path/../Frameworks") - #endif () - - #if (DIST_INSTALLER AND USE_OMP) - # message (WARNING "The build mode is set to distributable installer with OpenMP enabled and will not run from source") - # set (INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") - # set (CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) - # set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - # set (CMAKE_SKIP_BUILD_RPATH FALSE) - #endif() else () if (DIST_INSTALLER) set (INSTALL_BIN_DIR lib) @@ -232,9 +203,6 @@ add_subdirectory (share) add_subdirectory (scripts) add_subdirectory (test_apps) - - - ############################################################################### # CPack Installation # ############################################################################### diff --git a/apps/pythonapi/vapor/dataset.py b/apps/pythonapi/vapor/dataset.py index 9f62c0936..8ed80ab76 100644 --- a/apps/pythonapi/vapor/dataset.py +++ b/apps/pythonapi/vapor/dataset.py @@ -47,9 +47,34 @@ def NewRenderer(self, Class: Renderer) -> Renderer: def GetName(self): return str(self.id) + + def __str__(self): + output = [] + # Dataset Name + output.append(f"Dataset: {self.GetName()}") + # Dimensions + output.append("Dimensions:") + for dim in self.GetDimensionNames(): + output.append(f" {dim}: {self.GetDimensionLength(dim, 0)}") + # Coordinates + coord_var_names = self.GetCoordVarNames() + if len(coord_var_names) > 0: + output.append(f"Coordinate Variable Names: {coord_var_names}") + # Variables + output.append("Data Variables:") + for var in self.GetDataVarNames(): + output.extend([ + f" {var}", + f" Dimensionality: {self.GetVarGeometryDim(var)}", + f" Number of Timesteps: {self.GetNumTimeSteps(var)}", + f" Coordinates: {self.GetVarCoordVars(var, True)}", + f" Data Range: {self.GetDataRange(var)}" + ]) + + return "\n".join(output) def __repr__(self): - return f'Dataset("{self.GetName()}")' + return self.__str__() def GetTransform(self): pm = self.ses.ce.GetParamsMgr() @@ -62,7 +87,6 @@ def GetDataRange(self, varname: str, atTimestep: int = 0): self._wrappedInstance.GetDataRange(atTimestep, varname, 0, 0, c_range) return list(c_range) - @staticmethod def GetDatasetTypes(): return [VDC, WRF, CF, MPAS, BOV, UGRID] diff --git a/apps/pythonapi/vapor/transferfunction.py b/apps/pythonapi/vapor/transferfunction.py index 95e74023f..7fabc621f 100644 --- a/apps/pythonapi/vapor/transferfunction.py +++ b/apps/pythonapi/vapor/transferfunction.py @@ -60,6 +60,8 @@ def flatten(l): return list(flatten(l)) def __rgbToHsv(self, rgb): + if len(rgb) != 3: + raise ValueError("rgb list must have 3 values") return [*self._params.rgbToHsv(rgb)] def SetOpacityNormalizedControlPoints(self, cp: list[tuple[float, float]]): diff --git a/apps/vaporgui/ParticleEventRouter.cpp b/apps/vaporgui/ParticleEventRouter.cpp index d616b0741..611dde24e 100644 --- a/apps/vaporgui/ParticleEventRouter.cpp +++ b/apps/vaporgui/ParticleEventRouter.cpp @@ -41,6 +41,7 @@ ParticleEventRouter::ParticleEventRouter(QWidget *parent, ControlExec *ce) : Ren // (new PShowIf(ParticleParams::RenderRadiusVariableTag))->Not()->Equals("")->Then({ // (new PDoubleSliderEdit(ParticleParams::RenderRadiusVariableStrengthTag, "Radius Variable Strength"))->SetRange(0.001, 1)->AllowUserRange(true)->EnableDynamicUpdate() // }), + (new PButton("Recalculate Base Radius", [](ParamsBase *p){ p->SetValueLong(ParticleParams::RecalculateRadiusBaseRequestTag, "", true); })), new PCheckbox(ParticleParams::ShowDirectionTag, "Show direction"), (new PDoubleSliderEdit(ParticleParams::DirectionScaleTag, "Length scale"))->SetRange(0.0001, 10)->AllowUserRange(true)->EnableDynamicUpdate()->EnableBasedOnParam(ParticleParams::ShowDirectionTag), (new PXFieldVariableSelector)->ShowParticleVars()->EnableBasedOnParam(ParticleParams::ShowDirectionTag), diff --git a/buildutils/ConfigurationFunctions.cmake b/buildutils/ConfigurationFunctions.cmake index 98c3d9fe3..554a0779e 100644 --- a/buildutils/ConfigurationFunctions.cmake +++ b/buildutils/ConfigurationFunctions.cmake @@ -24,7 +24,7 @@ function(configure_apple_deployment_target) endfunction() function(tag_commit_hash) - #if (CMAKE_BUILD_TYPE STREQUAL "Release") + if (CMAKE_BUILD_TYPE STREQUAL "Release") get_git_head_revision (GIT_REFSPEC VERSION_COMMIT) execute_process ( COMMAND git rev-parse --short ${VERSION_COMMIT} @@ -32,14 +32,15 @@ function(tag_commit_hash) OUTPUT_VARIABLE VERSION_COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE ) - #endif () + endif () string (TIMESTAMP VERSION_DATE UTC) if (VERSION_RC) - set (VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}.${VERSION_RC}) + set (VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}.${VERSION_RC} ) else () set (VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}) endif () set (VERSION_STRING_FULL ${VERSION_STRING}.${VERSION_COMMIT} PARENT_SCOPE) + set (VERSION_STRING ${VERSION_STRING} PARENT_SCOPE) endfunction() function(set_compiler_flags) @@ -65,7 +66,7 @@ endFunction() function(find_bundled_python) # FindPython supports Python_ROOT_DIR however vapor's bundled python distribution # does not conform to its requirements so this manually configures the results - message("Using bundled python ${PYTHONVERSION}...") + message("Using bundled python ${PYTHONVERSION}") set(Python_VERSION "${PYTHONVERSION}") set(Python_NumPy_INCLUDE_DIRS "${NUMPY_INCLUDE_DIR}") unset(Python_LIBRARIES) # This is required for find_library to work in certain cases @@ -79,7 +80,7 @@ function(find_bundled_python) set(Python_SITELIB "${PYTHONPATH}/Lib/site-packages") set(Python_INCLUDE_DIRS "${THIRD_PARTY_DIR}/Python${PYTHONVERSION}/include") else() - set(Python_SITELIB "${PYTHONPATH}/site-packages" PARENT_SCOPE) + set(Python_SITELIB "${PYTHONPATH}/site-packages") if (NOT DEFINED Python_INCLUDE_DIRS) set(Python_INCLUDE_DIRS "${THIRD_PARTY_INC_DIR}/python${PYTHONVERSION}") message("Python_INCLUDE_DIRS ${THIRD_PARTY_INC_DIR}/python${PYTHONVERSION}") diff --git a/include/vapor/ParticleParams.h b/include/vapor/ParticleParams.h index 1ed66e3cf..9c060609a 100644 --- a/include/vapor/ParticleParams.h +++ b/include/vapor/ParticleParams.h @@ -40,6 +40,7 @@ class PARAMS_API ParticleParams : public RenderParams { static const std::string RenderRadiusVariableStrengthTag; static const std::string RenderRadiusBaseTag; + static const std::string RecalculateRadiusBaseRequestTag; static const std::string RenderLegacyTag; static const std::string LightingEnabledTag; diff --git a/include/vapor/ParticleRenderer.h b/include/vapor/ParticleRenderer.h index 87739560e..33a8890a8 100644 --- a/include/vapor/ParticleRenderer.h +++ b/include/vapor/ParticleRenderer.h @@ -87,12 +87,14 @@ class RENDER_API ParticleRenderer : public Renderer { void _clearCache() {} + bool _particleBaseSizeIsDirty() const; bool _particleCacheIsDirty() const; bool _colormapCacheIsDirty() const; void _resetParticleCache(); void _resetColormapCache(); int _generateParticlesLegacy(Grid*& grid, std::vector& vecGrids); int _getGrids(Grid*& grid, std::vector& vecGrids) const; + template void UploadDataBuffer(vector buffer); void _generateTextureData(const Grid* grid, const std::vector& vecGrids); void _computeBaseRadius(); void _renderParticlesLegacy(const Grid* grid, const std::vector& vecGrids) const; diff --git a/lib/params/ParticleParams.cpp b/lib/params/ParticleParams.cpp index 13d46ba7b..c6d5ec645 100644 --- a/lib/params/ParticleParams.cpp +++ b/lib/params/ParticleParams.cpp @@ -15,6 +15,7 @@ const std::string ParticleParams::StrideTag = "StrideTag"; const std::string ParticleParams::RenderRadiusScalarTag = "RenderRadiusScalarTag"; PARAMS_IMPL_TAG(ParticleParams, RenderRadiusVariableTag); PARAMS_IMPL_TAG(ParticleParams, RenderRadiusVariableStrengthTag); +PARAMS_IMPL_TAG(ParticleParams, RecalculateRadiusBaseRequestTag); const std::string ParticleParams::LightingEnabledTag = "LightingEnabledTag"; const std::string ParticleParams::RenderRadiusBaseTag = "RenderRadiusBaseTag"; const std::string ParticleParams::RenderLegacyTag = "RenderLegacyTag"; diff --git a/lib/render/ParticleRenderer.cpp b/lib/render/ParticleRenderer.cpp index 7cedd7f31..92a90b9b1 100644 --- a/lib/render/ParticleRenderer.cpp +++ b/lib/render/ParticleRenderer.cpp @@ -93,6 +93,11 @@ int ParticleRenderer::_paintGL(bool) glEnable(GL_DEPTH_TEST); bool regenerateParticles = false; + bool recomputeBaseRadius = false; + + if (_particleBaseSizeIsDirty()) + recomputeBaseRadius = true; + if (_particleCacheIsDirty()) { _resetParticleCache(); regenerateParticles = true; @@ -116,10 +121,10 @@ int ParticleRenderer::_paintGL(bool) _renderParticlesLegacy(grid, vecGrids); } else { - if (regenerateParticles) { + if (regenerateParticles) _generateTextureData(grid, vecGrids); + if (recomputeBaseRadius) _computeBaseRadius(); - } _renderParticlesHelper(); } @@ -197,6 +202,18 @@ static void SetupParticleDirectionGL(const int VAO, const int VBO, const bool dy glBindVertexArray(0); } +bool ParticleRenderer::_particleBaseSizeIsDirty() const { + auto p = GetActiveParams(); + if (p->GetValueLong(ParticleParams::RecalculateRadiusBaseRequestTag, false)) { + p->SetValueLong(ParticleParams::RecalculateRadiusBaseRequestTag, "", false); + return true; + } + if (_cacheParams.varName != p->GetVariableName()) return true; + if (_cacheParams.radiusVarName != p->GetValueString( ParticleParams::RenderRadiusVariableTag, "")) return true; + if (_cacheParams.stride != p->GetValueLong( ParticleParams::StrideTag, 1)) return true; + return false; +} + bool ParticleRenderer::_particleCacheIsDirty() const { auto p = GetActiveParams(); @@ -378,8 +395,9 @@ int ParticleRenderer::_getGrids(Grid*& grid, std::vector& vecGrids) const return 0; } -template static void UploadDataBuffer(vector buffer) { +template void ParticleRenderer::UploadDataBuffer(vector buffer) { glBufferData(GL_ARRAY_BUFFER, sizeof(T) * buffer.size(), buffer.data(), GL_STATIC_DRAW); + _particlesCount = buffer.size(); } void ParticleRenderer::_generateTextureData(const Grid* grid, const std::vector& vecGrids) { @@ -389,18 +407,12 @@ void ParticleRenderer::_generateTextureData(const Grid* grid, const std::vector< auto node = grid->ConstNodeBegin(_cacheParams.boxMin, _cacheParams.boxMax); auto nodeEnd = grid->ConstNodeEnd(); CoordType coordsBuf; - vector dirs; - - if (showDir) for (int i = 0; i < 3; i++) dirs.push_back(vecGrids[i]->cbegin(_cacheParams.boxMin, _cacheParams.boxMax)); - if (dynamicSize) dirs.push_back(vecGrids[vecGrids.size()-1]); struct PointDataT {vec3 pos; float val;}; vector pointData; struct DirectionDataT {vec3 pos; vec3 norm; float val;}; vector directionData; struct PointDynSizeDataT {vec3 pos; float val; float radius;}; vector pointDynSizeData; struct DirectionDynSizeDataT {vec3 pos; vec3 norm; float val; float radius;}; vector directionDynSizeData; - _particlesCount = grid->GetCoordDimensions(1)[0] / stride; - if (showDir) { SetupParticleDirectionGL(_VAO, _VBO, dynamicSize); directionData.reserve(_particlesCount); @@ -419,21 +431,26 @@ void ParticleRenderer::_generateTextureData(const Grid* grid, const std::vector< const vec3 p = CoordTypeToVec3(coordsBuf); if (showDir){ - const glm::vec3 norm(*(dirs[0]), *(dirs[1]), *(dirs[2])); + const glm::vec3 norm( + vecGrids[0]->GetValueAtIndex(*node), + vecGrids[1]->GetValueAtIndex(*node), + vecGrids[2]->GetValueAtIndex(*node) + ); if (dynamicSize) - directionDynSizeData.push_back({p, norm, value, *(dirs[dirs.size()-1])}); + directionDynSizeData.push_back({p, norm, value, vecGrids[vecGrids.size()-1]->GetValueAtIndex(*node)}); else directionData.push_back({p, norm, value}); } else { if (dynamicSize) - pointDynSizeData.push_back({p, value, *(dirs[dirs.size()-1])}); +// pointDynSizeData.push_back({p, value, *(dirs[dirs.size()-1])}); + pointDynSizeData.push_back({p, value, vecGrids[vecGrids.size()-1]->GetValueAtIndex(*node)}); + else pointData.push_back({p, value}); } } step: ++node, ++i; - for (auto &it : dirs) ++it; } glBindVertexArray(_VAO);