CMakeLists.txt 4.02 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 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_HMAT_SCALFMM CXX C)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SCALFMM_CXX_FLAGS}")

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

15
16
# Options
OPTION( SCALFMM_ADDON_HMAT "Set to ON to build ScalFMM HMat interface" OFF )
17
18
19

# if ask to build addon
if(SCALFMM_ADDON_HMAT)
BRAMAS Berenger's avatar
BRAMAS Berenger committed
20
        list(APPEND FUSE_LIST "SCOTCH")
21
22
23
        set(SCOTCH_NOT_FOUND $ENV{SCOTCH_LIB})
        if(NOT SCOTCH_NOT_FOUND) 
            MESSAGE(STATUS " SCOTCH not found " )
BRAMAS Berenger's avatar
BRAMAS Berenger committed
24
25
26
27
28
29
        else()
            OPTION( SCALFMM_USE_SCOTCH "Set to ON to use scotch" ON )
            if (SCALFMM_USE_SCOTCH)
               include_directories($ENV{SCOTCH_INC})
               SET(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES};-L$ENV{SCOTCH_LIB};-lscotch;-lscotcherr")        
            endif()
30
        endif()
BRAMAS Berenger's avatar
BRAMAS Berenger committed
31

32
33
34
35
36
37
38
        # first build lib scalfmmhmat
        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
39
        add_library( scalfmmhmat ${source_lib_files} )
40
        
41
42
43
44
45
        # Add blas library (even if it is set to off)
        target_link_libraries( scalfmmhmat scalfmm)

        # Adding the entire project dir as an include dir
        INCLUDE_DIRECTORIES(
46
47
             ${SCALFMM_BINARY_DIR}/Src
             ${SCALFMM_SOURCE_DIR}/Src
48
49
             ${SCALFMM_INCLUDES}
        )
50
51
52
53

        # Install lib
        install( TARGETS scalfmmhmat ARCHIVE DESTINATION lib )

54
55
        # Install headers
        SET(my_include_dirs "Src/Blocks" "Src/Clustering" "Src/Containers" "Src/Utils" "Src/Viewers" "CClusteringLibrary")
56

57
58
59
60
61
62
63
        FOREACH(my_dir ${my_include_dirs})  
            file(GLOB               
                hpp_in_dir
                ${my_dir}/*.hpp ${my_dir}/*.h
            )
            INSTALL( FILES ${hpp_in_dir} DESTINATION include/ScalFmm/HMat/${my_dir} )
        ENDFOREACH()
64

65
66
        # Add C Clustering Library
        file( GLOB_RECURSE ccl_lib_files CClusteringLibrary/*.c )
67
        add_library( cclusteringlib ${ccl_lib_files} )
68
69
70
71
        INCLUDE_DIRECTORIES(CClusteringLibrary/)
        target_link_libraries( cclusteringlib scalfmm)
        install( TARGETS cclusteringlib ARCHIVE DESTINATION lib )

72
        # Tests
73
        file( GLOB_RECURSE source_tests_files Tests/*.cpp )
74
        INCLUDE_DIRECTORIES( ${SCALFMM_BINARY_DIR}/Src )
75
76

        # Then build test files
77
        SET(hmat_list_execs "")
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
        foreach(exec ${source_tests_files})
                get_filename_component(
                        execname ${exec}
                        NAME_WE
                )

            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 )
                        add_executable(	${execname} ${exec} )
99
                        # link to scalfmm and scalfmmhmat and cclusteringlib
100
101
102
103
                        target_link_libraries(
                                ${execname}
                                ${scalfmm_lib}
                                scalfmmhmat
104
105
                                cclusteringlib
                                ${SCALFMM_LIBRARIES}
106
                                )
107
                         LIST(APPEND hmat_list_execs ${execname})
108
109
                endif()
        endforeach(exec)
110
111
        
        add_custom_target(hmat DEPENDS ${hmat_list_execs})
112
endif()