-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
56 lines (41 loc) · 1.77 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.9)
project(BlasBit)
enable_language(Fortran)
set(SOURCES
src/main.F90
)
option(USE_BLAS "Linking with BLAS or with DDOT_BLAS" OFF)
message(STATUS "Linking with BLAS or with DDOT_BLAS: " ${USE_BLAS})
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-backtrace")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-range-check")
endif()
if(USE_BLAS)
find_package(BLAS REQUIRED)
message(STATUS "BLAS LIBRARY: " ${BLAS_LIBRARIES})
foreach(PROGRAM_BIT 32 64)
math(EXPR IP "${PROGRAM_BIT} / 8")
add_executable (${PROJECT_NAME}${PROGRAM_BIT}_BLAS ${SOURCES})
target_link_libraries(${PROJECT_NAME}${PROGRAM_BIT}_BLAS ${BLAS_LIBRARIES})
set_target_properties(${PROJECT_NAME}${PROGRAM_BIT}_BLAS PROPERTIES COMPILE_FLAGS "-DIP=${IP} -DLIBRARY=0 -DPROGRAM=${PROGRAM_BIT}")
endforeach()
else()
option(USE_STATIC "Build static DDOT_BLAS library" OFF)
message(STATUS "Build static DDOT_BLAS library: " ${USE_STATIC})
if(USE_STATIC)
set(LIBRARY_TYPE "static")
else()
set(LIBRARY_TYPE "shared")
endif()
add_subdirectory(BLAS)
link_directories(${CMAKE_BINARY_DIR}/BLAS)
foreach(PROGRAM_BIT 32 64)
math(EXPR IP "${PROGRAM_BIT} / 8")
foreach(LIBRARY_BIT 32 64)
add_executable (${PROJECT_NAME}${PROGRAM_BIT}_${LIBRARY_BIT} ${SOURCES})
target_link_libraries(${PROJECT_NAME}${PROGRAM_BIT}_${LIBRARY_BIT} DDOT_BLAS${LIBRARY_BIT})
add_dependencies (${PROJECT_NAME}${PROGRAM_BIT}_${LIBRARY_BIT} DDOT_BLAS${LIBRARY_BIT}-${LIBRARY_TYPE})
set_target_properties(${PROJECT_NAME}${PROGRAM_BIT}_${LIBRARY_BIT} PROPERTIES COMPILE_FLAGS "-DIP=${IP} -DLIBRARY=${LIBRARY_BIT} -DPROGRAM=${PROGRAM_BIT}")
endforeach()
endforeach()
endif()