CMakeLists.txt 2.33 KB
Newer Older
1 2 3 4 5 6
# check if compiling into source directories
STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource)
if(insource)
    MESSAGE(FATAL_ERROR "${PROJECT_NAME} requires an out of source build. Goto scalfmm/Build and tapes cmake ../")
endif(insource)

7 8 9 10
# Configuration du projet
project(Lib_scalfmm)
set(LIBRARY_OUTPUT_PATH ../lib/${CMAKE_BUILD_TYPE})

11
ADD_DEFINITIONS(${ScaLFMM_CXX_FLAGS})
BRAMAS Berenger's avatar
BRAMAS Berenger committed
12

13 14 15 16 17 18 19
# Searching all cpp file
file(
	GLOB_RECURSE
	source_lib_files
	./*.cpp
)

20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
# Add CUDA files once they are compiled from cu to .o
if(ScalFMM_USE_CUDA)
    # Find all the CU files in my project
    file(GLOB_RECURSE source_cu_files ./*.cu)
 
    # Iterate and add builind command for each file
    set( SCALFMM_CUDA_SOURCES "" )
    FOREACH (_file ${source_cu_files})
 
        GET_FILENAME_COMPONENT (_filewe ${_file} NAME_WE)
        SET (_filehpp_output ${CMAKE_CURRENT_BINARY_DIR}/${_filewe}.o)
 
        ADD_CUSTOM_COMMAND(OUTPUT  ${_filehpp_output}
                  DEPENDS ${_file}
                  COMMAND echo ARGS Compiling ${_filewe}
BRAMAS Berenger's avatar
BRAMAS Berenger committed
35
                  COMMAND nvcc ARGS -I${CUDA_NEEDED_INCLUDE_DIRS} -c ${_file} -o ${_filehpp_output} ${CUSTOM_CUDA_FLAGS})
36 37 38 39 40 41 42
 
        LIST (APPEND SCALFMM_CUDA_SOURCES ${_filehpp_output})
    ENDFOREACH ()
 
    MESSAGE( STATUS "SCALFMM_CUDA_SOURCES          = ${SCALFMM_CUDA_SOURCES}" )
endif()

43 44 45 46 47
# Adding cpp files to project
add_library(
	scalfmm
	STATIC
	${source_lib_files}
48
	${SCALFMM_CUDA_SOURCES}
49 50
)

51 52 53
# Add blas library (even if it is set to off)
target_link_libraries(
	scalfmm
54 55
	${scalfmm_lib}
	${SCALFMM_LIBRARIES}
56 57
)

58 59
# Adding the entire project dir as an include dir
INCLUDE_DIRECTORIES(
60
     ${CMAKE_SOURCE_DIR}/Src 
berenger-bramas's avatar
berenger-bramas committed
61
     ${CMAKE_BINARY_DIR}/Src 
62 63
     ${SCALFMM_INCLUDES}
     
64 65
)

66 67 68 69 70

# Install lib
install( TARGETS scalfmm ARCHIVE DESTINATION lib )

# Install header
berenger-bramas's avatar
berenger-bramas committed
71
SET(my_include_dirs "."
72
  "Arranger"        "Core"           "Utils"
aetcheve's avatar
aetcheve committed
73 74
  "Kernels/Chebyshev"       "Components"       "Extensions"  
  "Containers"       "Files"       "Kernels/Spherical"
75 76
  "Kernels/P2P" "Kernels/Taylor" "Kernels/ROtation"
  "Kernels/Uniform" "Kernels/Interpolation")
berenger-bramas's avatar
berenger-bramas committed
77

78 79 80
FOREACH(my_dir ${my_include_dirs})	
	file(GLOB 	 	 	 	
	 	hpp_in_dir
81
		${my_dir}/*.hpp ${my_dir}/*.h
82
	)
83
	INSTALL( FILES ${hpp_in_dir} DESTINATION include/${my_dir} )
84
ENDFOREACH()
85

86
INSTALL( FILES "${CMAKE_BINARY_DIR}/Src/ScalFmmConfig.h" DESTINATION include/Utils/${my_dir} )
87