CMakeLists.txt 3.08 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
35
36
37
38
39
40
set(source_lib_files_enabled)
foreach(exec ${source_lib_files}) 
	set(compile_exec "TRUE")
	
	foreach(fuse_key ${FUSE_LIST})
	    file(STRINGS "${exec}" lines_fuse REGEX "@FUSE_${fuse_key}")
	    if(lines_fuse)
		    if( NOT SCALFMM_USE_${fuse_key} )
			    MESSAGE( STATUS "This needs ${fuse_key} = ${exec}" )
			    set(compile_exec "FALSE")
		    endif()
	    endif()
	endforeach()

	# Dependency are OK
	if( compile_exec )
        list(APPEND source_lib_files_enabled ${exec})
	endif()
endforeach(exec)


41
# Add CUDA files once they are compiled from cu to .o
42
if(SCALFMM_USE_CUDA)
43
44
45
46
47
48
49
50
51
52
53
54
55
    # 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
56
                  COMMAND nvcc ARGS -I${CUDA_NEEDED_INCLUDE_DIRS} -c ${_file} -o ${_filehpp_output} ${CUSTOM_CUDA_FLAGS})
57
58
59
60
61
62
63
 
        LIST (APPEND SCALFMM_CUDA_SOURCES ${_filehpp_output})
    ENDFOREACH ()
 
    MESSAGE( STATUS "SCALFMM_CUDA_SOURCES          = ${SCALFMM_CUDA_SOURCES}" )
endif()

64
65
66
# Adding cpp files to project
add_library(
	scalfmm
67
	${source_lib_files_enabled}
68
	${SCALFMM_CUDA_SOURCES}
69
70
)

71
72
73
# Add blas library (even if it is set to off)
target_link_libraries(
	scalfmm
74
75
	${scalfmm_lib}
	${SCALFMM_LIBRARIES}
76
77
)

78
79
# Adding the entire project dir as an include dir
INCLUDE_DIRECTORIES(
80
81
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
82
     ${SCALFMM_INCLUDES}
83
84
)

85
86

# Install lib
87
install( TARGETS scalfmm DESTINATION lib )
88
89

# Install header
berenger-bramas's avatar
berenger-bramas committed
90
SET(my_include_dirs "."
91
  "Arranger"        "Core"           "Utils"
aetcheve's avatar
aetcheve committed
92
93
  "Kernels/Chebyshev"       "Components"       "Extensions"  
  "Containers"       "Files"       "Kernels/Spherical"
94
  "Kernels/P2P" "Kernels/Taylor" "Kernels/Rotation"
95
  "Kernels/Uniform" "Kernels/Interpolation")
berenger-bramas's avatar
berenger-bramas committed
96

97
98
99
100
101
if(SCALFMM_ONLY_DEVEL)
    SET(my_include_dirs ${my_include_dirs} "GroupTree/Chebyshev"  "GroupTree/Core"  "GroupTree/Cuda"  "GroupTree/OpenCl"
        "GroupTree/Rotation"  "GroupTree/StarPUUtils"  "GroupTree/Taylor"  "GroupTree/TestKernel"  "GroupTree/Uniform")
endif()

102
103
104
FOREACH(my_dir ${my_include_dirs})	
	file(GLOB 	 	 	 	
	 	hpp_in_dir
105
		${my_dir}/*.hpp ${my_dir}/*.h
106
	)
107
	INSTALL( FILES ${hpp_in_dir} DESTINATION include/${my_dir} )
108
ENDFOREACH()
109

110
INSTALL( FILES "${SCALFMM_BINARY_DIR}/Src/ScalFmmConfig.h" DESTINATION include/${my_dir} )
111