CMakeLists.txt 1.31 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
project(TESTS_SCALFMM CXX)
berenger-bramas's avatar
berenger-bramas committed
8
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BUILD_TYPE})
9
ADD_DEFINITIONS( ${ScaLFMM_CXX_FLAGS})
berenger-bramas's avatar
berenger-bramas committed
10 11 12 13 14
# Find all code files
file(	
	GLOB_RECURSE
	source_tests_files
	./*.cpp
Matthias Messner's avatar
Matthias Messner committed
15 16
	)

17 18

# Adding the project sources dir as an include dir
19
INCLUDE_DIRECTORIES(
20 21
     ${SCALFMM_BINARY_DIR}/Src    
     ${SCALFMM_SOURCE_DIR}/Src   
22
     ${SCALFMM_INCLUDES}
23
)
berenger-bramas's avatar
berenger-bramas committed
24

25

berenger-bramas's avatar
berenger-bramas committed
26 27 28 29 30 31
# Add execs - 1 cpp = 1 exec
foreach(exec ${source_tests_files}) 
	get_filename_component(
		execname ${exec}
		NAME_WE
	)
32

33 34 35 36 37
	set(compile_exec "TRUE")
	
	foreach(fuse_key ${FUSE_LIST})
	    file(STRINGS "${exec}" lines_fuse REGEX "@FUSE_${fuse_key}")
	    if(lines_fuse)
38
		    if( NOT SCALFMM_USE_${fuse_key} )
39 40 41 42 43
			    MESSAGE( STATUS "This needs ${fuse_key} = ${exec}" )
			    set(compile_exec "FALSE")
		    endif()
	    endif()
	endforeach()
44 45 46

	# Dependency are OK
	if( compile_exec )
47
		add_executable(
Matthias Messner's avatar
Matthias Messner committed
48 49 50
				${execname}
				${exec}
				)
51
		SET_TARGET_PROPERTIES(${execname} PROPERTIES ENABLE_EXPORTS TRUE)
52 53
		target_link_libraries(
			${execname}
berenger-bramas's avatar
berenger-bramas committed
54
			${scalfmm_lib}
COULAUD Olivier's avatar
COULAUD Olivier committed
55
			${SCALFMM_LIBRARIES}
Matthias Messner's avatar
Matthias Messner committed
56
			)
57
	endif()
berenger-bramas's avatar
berenger-bramas committed
58
endforeach(exec)