Skip to content

Commit

Permalink
update the format of c code and update cmake to be compatible with macos
Browse files Browse the repository at this point in the history
  • Loading branch information
ares201005 committed Oct 3, 2024
1 parent 44287b4 commit 4efd5d2
Show file tree
Hide file tree
Showing 17 changed files with 10,068 additions and 8,619 deletions.
31 changes: 23 additions & 8 deletions openms/lib/fdtd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ include(FindGSL)

## maybe a better idea is to let user to install the gsl and provide it via LD_LIBRARY_PATH
##find_package(GSL COMPONENTS libgsl libgslcblas PATHS ${CMAKE_PREFIX_PATH} QUIET)

# Determine the operating system
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# macOS
set(LIB_POSTFIX "dylib")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# Linux
set(LIB_POSTFIX "so")
else()
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
endif()

if(GSL_FOUND)
message("GSL found!")
else()
Expand All @@ -24,12 +36,12 @@ else()
BUILD_COMMAND make
INSTALL_COMMAND make install
TEST_COMMAND "" # empty command, will not run tests during build
TEST_AFTER_INSTALL TRUE # Run tests after installation with "make check"
TEST_AFTER_INSTALL TRUE # Run tests after installation with "make check"
)
#set(gsl_lib "${PROJECT_SOURCE_DIR}/deps/lib/libgslcblas.so")
#set(gsl_cblas "${PROJECT_SOURCE_DIR}/deps/lib/libgslcblas.so")
set(GSL_LIBRARIES "${PROJECT_SOURCE_DIR}/deps/lib/libgslcblas.so" "${PROJECT_SOURCE_DIR}/deps/lib/libgsl.so")
set(GSL_LIBRARY "${PROJECT_SOURCE_DIR}/deps/lib/libgsl.so")
#set(gsl_lib "${PROJECT_SOURCE_DIR}/deps/lib/libgslcblas.${LIB_POSTFIX}")
#set(gsl_cblas "${PROJECT_SOURCE_DIR}/deps/lib/libgslcblas.${LIB_POSTFIX}")
set(GSL_LIBRARIES "${PROJECT_SOURCE_DIR}/deps/lib/libgslcblas.${LIB_POSTFIX}" "${PROJECT_SOURCE_DIR}/deps/lib/libgsl.${LIB_POSTFIX}")
set(GSL_LIBRARY "${PROJECT_SOURCE_DIR}/deps/lib/libgsl.${LIB_POSTFIX}")
set(GSL_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/deps/include/gsl")
endif()

Expand All @@ -50,7 +62,6 @@ energy.c
output.c
metalobj.c
memory.c
libpFDTD.a
transmap.c
timeupdate.c
source.c
Expand Down Expand Up @@ -89,16 +100,21 @@ include_directories(${Python3_INCLUDE_DIRS})
include_directories(${NUMPY_INCLUDE_DIR})
include_directories(${GSL_INCLUDE_DIRS})

link_directories(${Python3_LIBRARY_DIRS})

# Create _fdtdc Python extension module
add_library(_fdtdc SHARED ${SOURCES-C} ${WRAPPER-C})

#add_custom_command(TARGET _fdtdc COMMAND swig -python ${CMAKE_CURRENT_SOURCE_DIR}/pFDTD.i)
#add_custom_command(TARGET _fdtdc POST_BUILD COMMAND swig -python ${CMAKE_CURRENT_SOURCE_DIR}/pFDTD.i)

# Link against GSL library
target_link_libraries(_fdtdc PUBLIC ${GSL_LIBRARIES})
target_link_libraries(_fdtdc PUBLIC ${GSL_LIBRARIES} ${Python3_LIBRARIES})
target_include_directories(_fdtdc PUBLIC ${GSL_LIBRARIES})

message("")
message(" * C_FLAGS are: ${CMAKE_C_FLAGS}")
message("")

# Install _fdtdc Python extension module
set_target_properties(_fdtdc PROPERTIES PREFIX "")
Expand All @@ -121,4 +137,3 @@ install(TARGETS _fdtdc
#SET_SOURCE_FILES_PROPERTIES(pFDTD.i PROPERTIES SWIG_FLAGS "-includeall")
#SWIG_ADD_MODULE(pFDTD python pFDTD.i ${SOURCES-C})
#SWIG_LINK_LIBRARIES(pFDTD ${PYTHON_LIBRARIES})

Loading

0 comments on commit 4efd5d2

Please sign in to comment.