Skip to content

Commit

Permalink
prepare for integration into FS
Browse files Browse the repository at this point in the history
  handle ARM64 Mac build
  • Loading branch information
yhuang43 committed Mar 12, 2024
1 parent a7ae92d commit dc0cc41
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
17 changes: 16 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
# --------------------------------------------------
Expand Down
12 changes: 9 additions & 3 deletions gems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit dc0cc41

Please sign in to comment.