CMakeLists.txt 2.18 KB
Newer Older
1 2 3 4 5 6 7
# 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 ./Build and tapes cmake ../")
endif(insource)

project(Addons_fmmapi_scalfmm CXX)
8
ADD_DEFINITIONS( ${ScaLFMM_CXX_FLAGS})
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

# Active language
# -----------------------
ENABLE_LANGUAGE(CXX )
MESSAGE(STATUS " CXX  ${CMAKE_CXX_COMPILER_ID}" )

# Options
OPTION( SCALFMM_ADDON_FMMAPI "Set to ON to build ScaFMM FMM API interface" OFF )

# if ask to build addon
if(SCALFMM_ADDON_FMMAPI)
	# first build lib scalfmmapi
	set(LIBRARY_OUTPUT_PATH ../lib/${CMAKE_BUILD_TYPE})

	# Searching all cpp file
	file( GLOB_RECURSE source_lib_files Src/*.cpp )

	# Adding cpp files to project
27
	add_library( scalfmmapi ${source_lib_files} )
28 29 30 31 32

	# Add blas library (even if it is set to off)
	target_link_libraries( scalfmmapi scalfmm)

	# Adding the entire project dir as an include dir
33
	INCLUDE_DIRECTORIES(
34 35
         ${SCALFMM_BINARY_DIR}/Src 
         ${SCALFMM_SOURCE_DIR}/Src   
36 37
         ${SCALFMM_INCLUDES}
    )
38 39 40 41 42 43 44 45 46 47 48

	# Install lib
	install( TARGETS scalfmmapi ARCHIVE DESTINATION lib )

	# Install header
	SET(my_include_dirs "Src")
	
	file( GLOB hpp_in_dir Src/*.hpp )
	INSTALL( FILES ${hpp_in_dir} DESTINATION include/ScalFmm/FmmApi )

	file( GLOB_RECURSE source_tests_files Tests/*.cpp )
49
	INCLUDE_DIRECTORIES( ${SCALFMM_BINARY_DIR}/Src )
50 51 52 53 54 55 56 57

	# Then build test files
	foreach(exec ${source_tests_files}) 
		get_filename_component(
			execname ${exec}
			NAME_WE
		)

58 59 60 61 62
	    set(compile_exec "TRUE")
	
	    foreach(fuse_key ${FUSE_LIST})
	        file(STRINGS "${exec}" lines_fuse REGEX "@FUSE_${fuse_key}")
	        if(lines_fuse)
63
		        if( NOT SCALFMM_USE_${fuse_key} )
64 65 66 67 68
			        MESSAGE( STATUS "This needs ${fuse_key} = ${exec}" )
			        set(compile_exec "FALSE")
		        endif()
	        endif()
	    endforeach()
69 70 71 72 73 74 75 76 77 78 79

		# Dependency are OK
		if( compile_exec )
			add_executable(	${execname} ${exec} )
			# link to scalfmm and scalfmmapi
			target_link_libraries(
				${execname}
				${scalfmm_lib}
				scalfmmapi
				${BLAS_LIBRARIES}
				${LAPACK_LIBRARIES}
80
			    ${SCALFMM_LIBRARIES}
81 82 83 84 85
				)
		endif()
	endforeach(exec)
endif()