CMakeLists.txt 1.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
# 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)

project(Examples_scalfmm CXX)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BUILD_TYPE})
ADD_DEFINITIONS( ${ScaLFMM_CXX_FLAGS})
# Find all code files
file(	
	GLOB_RECURSE
	source_tests_files
	./*.cpp
	)


# Adding the project sources dir as an include dir
INCLUDE_DIRECTORIES(
     ${CMAKE_BINARY_DIR}/Src 
     ${CMAKE_SOURCE_DIR}/Src 
)


# Add execs - 1 cpp = 1 exec
foreach(exec ${source_tests_files}) 
	get_filename_component(
		execname ${exec}
		NAME_WE
	)

	set(compile_exec "TRUE")	

	# Test Blas dependency
	file(STRINGS "${exec}" lines_blas REGEX "@FUSE_BLAS")
	if(lines_blas)
		if( NOT ScalFMM_USE_BLAS )
			MESSAGE( STATUS "This needs BLAS = ${exec}" )
			set(compile_exec "FALSE")
		endif()
	endif()

	# Test FFT dependency
	file(STRINGS "${exec}" lines_fft REGEX "@FUSE_FFT")
	if(lines_fft)
		if( NOT ScalFMM_USE_FFT )
			MESSAGE( STATUS "This needs FFT = ${exec}" )
			set(compile_exec "FALSE")
		endif()
	endif()

	# Test MPI dependency
	file(STRINGS "${exec}" lines_mpi REGEX "@FUSE_MPI")
	if(lines_mpi)
		if( NOT ScalFMM_USE_MPI )
			MESSAGE( STATUS "This needs MPI = ${exec}" )
			set(compile_exec "FALSE")
		endif()
	endif()

	# Dependency are OK
	if( compile_exec )
		add_executable(
				${execname}
				${exec}
				)
		SET_TARGET_PROPERTIES(${execname} PROPERTIES ENABLE_EXPORTS TRUE)
		target_link_libraries(
			${execname}
			${scalfmm_lib}
			${SCALFMM_LIBRARIES}
			)
	endif()
74 75 76 77
	
# Install bin
install( TARGETS ${execname}   DESTINATION bin )
	
78
endforeach(exec)