CMakeLists.txt 2.8 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 ./Build and tapes cmake ../")
endif(insource)

7 8
project(ADDONS_CKERNELAPI_SCALFMM CXX C)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SCALFMM_CXX_FLAGS}")
9 10 11 12 13 14 15 16

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


# if ask to build addon
17
if(SCALFMM_ADDON_CKERNELAPI)
18 19
        # first build lib scalfmmckernelapi
        set(LIBRARY_OUTPUT_PATH ../lib/${CMAKE_BUILD_TYPE})
20

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

24
        # Adding cpp files to project
25
        add_library( scalfmmckernelapi ${source_lib_files} )
26

27 28
        # Add blas library (even if it is set to off)
        target_link_libraries( scalfmmckernelapi scalfmm)
29

30 31
        # Adding the entire project dir as an include dir
        INCLUDE_DIRECTORIES(
32 33
         ${SCALFMM_BINARY_DIR}/Src
         ${SCALFMM_SOURCE_DIR}/Src
34 35 36
         ${SCALFMM_INCLUDES}
    )

37
        # Install lib
38
        install( TARGETS scalfmmckernelapi ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
39 40 41 42

        # Install header
        SET(my_include_dirs "Src")

43
        file( GLOB hpp_in_dir Src/*.hpp Src/*.h)
44 45 46
        INSTALL( FILES ${hpp_in_dir} DESTINATION include/ScalFmm/CKernelApi )

        file( GLOB_RECURSE source_tests_files Tests/*.c )
47
        INCLUDE_DIRECTORIES( ${SCALFMM_BINARY_DIR}/Src )
48

49 50 51 52 53 54 55 56 57 58 59 60
        # Then build test files
        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)
61
                        if( NOT SCALFMM_USE_${fuse_key} )
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
                                MESSAGE( STATUS "This needs ${fuse_key} = ${exec}" )
                                set(compile_exec "FALSE")
                        endif()
                endif()
            endforeach()

                # Dependency are OK
                if( compile_exec )
                        add_executable(	${execname} ${exec} )
                        # link to scalfmm and scalfmmckernelapi
                        target_link_libraries(
                                ${execname}
                                ${scalfmm_lib}
                                scalfmmckernelapi
                                # ${BLAS_LIBRARIES}
                                # ${LAPACK_LIBRARIES}
                            ${SCALFMM_LIBRARIES}
                                )
                endif()
        endforeach(exec)
endif()