diff --git a/CMakeLists.txt b/CMakeLists.txt index a2681c3..03a2497 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,9 +45,20 @@ message(STATUS "ITK_DIR=${ITK_DIR} pybind11_DIR=${pybind11_DIR}") # -------------------------------------------------- # build settings # -------------------------------------------------- +if(APPLE) + set(CMAKE_C_COMPILER "/usr/bin/clang") + set(CMAKE_CXX_COMPILER "/usr/bin/clang++") + # set -DAPPLE_ARM64=ON on cmake command line for arm64 build + if(APPLE_ARM64) + set(CMAKE_OSX_ARCHITECTURES "arm64") + add_definitions(-DARM64 -DDarwin -DPNG_ARM_NEON_OPT=0) + endif() +endif() # warnings -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-absolute-value -Wno-sign-compare -Wno-write-strings -Wno-unused-result -Wno-unused-parameter") +if(NOT APPLE_ARM64) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-absolute-value -Wno-sign-compare -Wno-write-strings -Wno-unused-result -Wno-unused-parameter") +endif() # clang complains about -Wno-unused-but-set-variable and says to use -Wno-unused-const-variable if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -75,6 +86,10 @@ if(PROFILING) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") endif() +message(STATUS "C/C++ standard set to ${CMAKE_CXX_STANDARD}, CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}, CMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}, CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") +message(STATUS "For HOST_OS=${HOST_OS} CMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}") +message(STATUS "For HOST_OS=${HOST_OS} CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") + # -------------------------------------------------- # build samseg # -------------------------------------------------- diff --git a/gems/CMakeLists.txt b/gems/CMakeLists.txt index c6f5db1..52040ed 100755 --- a/gems/CMakeLists.txt +++ b/gems/CMakeLists.txt @@ -30,10 +30,14 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${GEMS_RUNTIME_PATH}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${GEMS_RUNTIME_PATH}) set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_FLAGS "-fPIC -fpermissive -msse2 -mfpmath=sse") +if(NOT APPLE_ARM64) + set(CMAKE_CXX_FLAGS "-fPIC -fpermissive -msse2 -mfpmath=sse") +endif() -# SC 2023/04/04: Commented out as it causes problem with Windows build -# add_compile_options(-Wno-inconsistent-missing-override -Wno-self-assign-field) +if(NOT WIN32) + # SC 2023/04/04: Commented out as it causes problem with Windows build + add_compile_options(-Wno-inconsistent-missing-override -Wno-self-assign-field) +endif() # to set additional debug cxxflags: # export GEMS_DEBUG_CXXFLAG="-DGEMS_DEBUG_RASTERIZE_VOXEL_COUNT" @@ -158,6 +162,8 @@ set(SOURCES_DYN kvlAtlasMeshJacobianDeterminantDrawer.cxx ) +message(WARNING "ZLIB_LIBRARIES=${ZLIB_LIBRARIES} ITK_LIBRARIES=${ITK_LIBRARIES}") + # gems libary add_library(kvlGEMSCommon ${SOURCES}) target_link_libraries(kvlGEMSCommon ${ZLIB_LIBRARIES} ${ITK_LIBRARIES}) diff --git a/setup.py b/setup.py index ec00596..92a6a63 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def run(self): '-H.' ] # Pass environment variables to CMake - for k in ['ITK_DIR', 'ZLIB_INCLUDE_DIR', 'ZLIB_LIBRARY']: + for k in ['ITK_DIR', 'ZLIB_INCLUDE_DIR', 'ZLIB_LIBRARY', 'pybind11_DIR', 'CMAKE_C_COMPILER', 'CMAKE_CXX_COMPILER', 'APPLE_ARM64', 'CMAKE_VERBOSE_MAKEFILE', 'CMAKE_RULE_MESSAGES']: try: path = os.path.abspath(os.environ[k].replace('"', '')) except KeyError: