From 4aa0c210565dffc460322d72d9a9538aceac18e2 Mon Sep 17 00:00:00 2001 From: Qianqian Fang Date: Mon, 11 Nov 2024 10:43:00 -0500 Subject: [PATCH] [ci] avoid static library in macos-12 runner --- .github/workflows/build_all.yml | 2 +- src/CMakeLists.txt | 106 ++++++++++++++++++++++---------- 2 files changed, 74 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index 7f34e53f..4f1d551b 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2c0771be..329fed23 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) @@ -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