Skip to content

Commit

Permalink
[ci] avoid static library in macos-12 runner
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Nov 11, 2024
1 parent 35fcb15 commit 4aa0c21
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ jobs:
make AR=g++ BACKEND=cudastatic USERLINKOPT='lib/libzmat.a -Wl,-Bstatic -lgomp -Wl,-Bdynamic'
ldd ../bin/mcx
elif [[ "$RUNNER_OS" == "macOS" ]]; then
mkdir build && cd build && cmake .. -DCMAKE_AR="/usr/local/bin/gcc-ar-12" -DCMAKE_RANLIB="/usr/local/bin/gcc-ranlib-12" && cat && make VERBOSE=1 && cd ..
mkdir build && cd build && cmake .. -DBUILD_MACOS12=on && cat && make VERBOSE=1 && cd ..
otool -L ../bin/mcx
otool -L ../mcxlab/mcx.mex*
else
Expand Down
106 changes: 73 additions & 33 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ find_package(OpenMP REQUIRED)
add_subdirectory(zmat)

option(BUILD_MEX "Build mex" ON)
option(BUILD_MACOS12 "Build macos-12" OFF)

if(BUILD_PYTHON)
add_subdirectory(pybind11)
Expand Down Expand Up @@ -54,44 +55,83 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Add include directories
include_directories(cjson ubj zmat zmat/easylzma)

# Add link directories
link_directories(zmat)

# Create mcx library
cuda_add_library(mcx STATIC
mcx_core.cu
mcx_core.h
mcx_utils.c
mcx_utils.h
mcx_shapes.c
mcx_shapes.h
mcx_bench.c
mcx_bench.h
mcx_mie.cpp
mcx_mie.h
mcx_tictoc.c
mcx_tictoc.h
cjson/cJSON.c
cjson/cJSON.h
ubj/ubj.h
ubj/ubjw.c
)

# Add all project units
cuda_add_executable(
mcx-exe
mcx.c
)
if(BUILD_MACOS12)

# Add link directories
link_directories(zmat)

# Create mcx library
cuda_add_executable(mcx
mcx.c
mcx_core.cu
mcx_core.h
mcx_utils.c
mcx_utils.h
mcx_shapes.c
mcx_shapes.h
mcx_bench.c
mcx_bench.h
mcx_mie.cpp
mcx_mie.h
mcx_tictoc.c
mcx_tictoc.h
cjson/cJSON.c
cjson/cJSON.h
ubj/ubj.h
ubj/ubjw.c
)

# Link options
target_link_libraries(
mcx-exe
OpenMP::OpenMP_CXX
zmat
)

else()

# Add link directories
link_directories(zmat)

# Create mcx library
cuda_add_library(mcx STATIC
mcx_core.cu
mcx_core.h
mcx_utils.c
mcx_utils.h
mcx_shapes.c
mcx_shapes.h
mcx_bench.c
mcx_bench.h
mcx_mie.cpp
mcx_mie.h
mcx_tictoc.c
mcx_tictoc.h
cjson/cJSON.c
cjson/cJSON.h
ubj/ubj.h
ubj/ubjw.c
)

# Add all project units
cuda_add_executable(
mcx-exe
mcx.c
)

# Link options
target_link_libraries(
mcx-exe
mcx OpenMP::OpenMP_CXX
zmat
)

endif()

set_target_properties(mcx-exe
PROPERTIES OUTPUT_NAME mcx)

# Link options
target_link_libraries(
mcx-exe
mcx OpenMP::OpenMP_CXX
zmat
)

if (BUILD_PYTHON)
cuda_add_library(_pmcx MODULE
Expand Down

0 comments on commit 4aa0c21

Please sign in to comment.