4 macro(add_libhoomd_source_dir dir)
5 add_subdirectory(${dir})
7 # find all source files in this directory
8 file(GLOB SRCS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*.cc)
9 file(GLOB CU_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*.cu)
10 file(GLOB HDRS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*.cuh)
12 # add them to the source group
13 source_group(${dir} FILES ${CU_SRCS} ${SRCS} ${HDRS})
15 # add them to the main libhoomd list
16 list(APPEND _libhoomd_sources ${SRCS} ${HDRS})
17 list(APPEND _libhoomd_cu_sources ${CU_SRCS})
18 endmacro(add_libhoomd_source_dir)
21 set(_libhoomd_sources "")
22 set(_libhoomd_cu_sources "")
24 # process all subdirectories, which add source files to _libhoomd_sources and _libhoomd_cu_sources
25 set(_dir_list analyzers communication computes data_structures extern
26 potentials python system updaters utils)
28 list(APPEND _dir_list computes_gpu cuda updaters_gpu)
31 foreach (dir ${_dir_list})
32 add_libhoomd_source_dir(${dir})
36 if (BUILD_SHARED_LIBS)
37 set (_libhoomd_shared SHARED)
38 endif (BUILD_SHARED_LIBS)
39 CUDA_COMPILE(_CUDA_GENERATED_FILES ${_libhoomd_cu_sources} OPTIONS ${CUDA_ADDITIONAL_OPTIONS} ${_libhoomd_shared})
40 source_group(cuda_generated FILES ${_CUDA_GENERATED_FILES})
43 add_library (libhoomd ${_libhoomd_sources} ${_CUDA_GENERATED_FILES})
45 ##################################
46 # change the name of the library if it is dynamic
47 if (NOT ENABLE_STATIC)
48 # link the library to its dependancies
49 target_link_libraries(libhoomd ${HOOMD_COMMON_LIBS})
52 # if we are compiling with MPI support built in, set appropriate
53 # compiler/linker flags
55 set_target_properties(libhoomd PROPERTIES COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS}")
56 endif(MPI_COMPILE_FLAGS)
58 set_target_properties(libhoomd PROPERTIES LINK_FLAGS "${MPI_CXX_LINK_FLAGS}")
62 # tweak the properties of the output to make a functional python module
63 set_target_properties(libhoomd PROPERTIES PREFIX "" OUTPUT_NAME "hoomd")
65 # .dylib is not regognized as a python module by python on Mac OS X
67 set_target_properties(libhoomd PROPERTIES SUFFIX ".so")
69 fix_cudart_rpath(libhoomd)
71 # set the rpath so that the lib can find other libs stashed in lib/hoomd
72 if (ENABLE_EMBED_CUDA)
73 set_target_properties(libhoomd PROPERTIES INSTALL_RPATH "$ORIGIN/../../hoomd;$ORIGIN/../hoomd")
74 endif (ENABLE_EMBED_CUDA)
76 # for non-app-bundle relocatable installs, set the install name of the lib for linking relative to bin/
77 if (NOT ENABLE_APP_BUNDLE_INSTALL)
78 set_target_properties(libhoomd PROPERTIES INSTALL_NAME_DIR "@executable_path/../lib/hoomd/python-module")
79 endif (NOT ENABLE_APP_BUNDLE_INSTALL)
80 endif (NOT ENABLE_STATIC)
83 # change the library name to something more sensible
85 set_target_properties(libhoomd PROPERTIES OUTPUT_NAME "libhoomd")
87 set_target_properties(libhoomd PROPERTIES OUTPUT_NAME "hoomd")
91 # due to the way that app bundle installs work with relative linking, hoomd.so must be installed into the bin dir, ugh!
92 if (ENABLE_APP_BUNDLE_INSTALL)
93 set(_hoomd_so_install_dir ${BIN_INSTALL_DIR})
94 else (ENABLE_APP_BUNDLE_INSTALL)
95 set(_hoomd_so_install_dir ${HOOMD_PYTHON_MODULE_DIR})
96 endif(ENABLE_APP_BUNDLE_INSTALL)
99 install(TARGETS libhoomd
100 LIBRARY DESTINATION ${_hoomd_so_install_dir}
101 ARCHIVE DESTINATION ${LIB_BASE_INSTALL_DIR}
104 add_subdirectory(api)