1+ cmake_minimum_required (VERSION 2.8.12)
2+
3+ # Setup cmake policies.
4+ foreach (p
5+ CMP0012
6+ CMP0013
7+ CMP0014
8+ CMP0022 # CMake 2.8.12
9+ CMP0025 # CMake 3.0
10+ CMP0053 # CMake 3.1
11+ CMP0054 # CMake 3.1
12+ CMP0074 # CMake 3.12
13+ CMP0075 # CMake 3.12
14+ CMP0083 # CMake 3.14
15+ CMP0093 # CMake 3.15
16+ )
17+ if (POLICY ${p} )
18+ cmake_policy (SET ${p} NEW)
19+ endif ()
20+ endforeach ()
21+
22+ project (PDC_LLSM_EXAM C)
23+
24+ set (LLSM_EXT_INCLUDE_DIRS "" )
25+ set (LLSM_EXT_LIBRARIES "" )
26+
27+
28+
29+ set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
30+
31+ find_package (PDC REQUIRED)
32+ if (PDC_FOUND)
33+ #message(STATUS "PDC include directory: ${PDC_INCLUDE_DIR}")
34+ set (LLSM_EXT_INCLUDE_DIRS ${PDC_INCLUDE_DIR}
35+ ${LLSM_EXT_INCLUDE_DIRS}
36+ )
37+ set (LLSM_EXT_LIBRARIES pdc ${LLSM_EXT_LIBRARIES} )
38+ endif ()
39+
40+ option (USE_SYSTEM_MPI "Use system-installed OpenMP." ON )
41+ if (USE_SYSTEM_MPI)
42+ find_package (MPI)
43+ if (MPI_FOUND)
44+ add_definitions (-DLLSM_ENABLE_MPI=1)
45+ SET (CMAKE_C_COMPILER ${MPI_C_COMPILER} )
46+ SET (CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER} )
47+ set (LLSM_EXT_INCLUDE_DIRS ${MPI_C_INCLUDE_PATH}
48+ ${LLSM_EXT_INCLUDE_DIRS}
49+ )
50+ set (LLSM_EXT_LIBRARIES ${MPI_C_LIBRARIES} ${LLSM_EXT_LIBRARIES} )
51+ endif ()
52+ endif ()
53+
54+ option (USE_SYSTEM_OPENMP "Use system-installed OpenMP." ON )
55+ if (USE_SYSTEM_OPENMP)
56+ find_package (OpenMP REQUIRED)
57+ if (OPENMP_FOUND)
58+ add_definitions (-DENABLE_OPENMP=1)
59+ set (ENABLE_OPENMP 1)
60+ set (OPENMP_LIBRARIES "${OpenMP_C_LIBRARIES} " )
61+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp" )
62+ else ()
63+ message (FATAL_ERROR "OpenMP not found" )
64+ endif ()
65+ endif ()
66+
67+ include_directories (
68+ ${LLSM_EXT_INCLUDE_DIRS}
69+ )
70+
71+
72+ # Find LibTIFF
73+ option (USE_LIB_TIFF "Enable LibTiff." ON )
74+ if (USE_LIB_TIFF)
75+ find_package (TIFF REQUIRED)
76+ if (TIFF_FOUND)
77+ set (LLSM_LIB_SOURCE
78+ llsm_aux/parallelReadTiff.c
79+ llsm_aux/csvReader.c
80+ llsm_aux/pdc_list.c
81+ )
82+ # Add the LibTIFF include directory to the include path
83+ include_directories (${TIFF_INCLUDE_DIRS} )
84+ add_library (llsm_tiff ${LLSM_LIB_SOURCE} )
85+ target_compile_options (llsm_tiff PRIVATE ${OpenMP_C_FLAGS} )
86+ target_link_libraries (llsm_tiff PUBLIC ${OpenMP_C_LIBRARIES} )
87+ target_link_libraries (llsm_tiff PUBLIC ${TIFF_LIBRARIES} )
88+ target_include_directories (llsm_tiff PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} /llsm)
89+
90+ add_executable (llsm_importer llsm_importer.c)
91+ target_link_libraries (llsm_importer ${PDC_EXT_LIB_DEPENDENCIES} pdc ${TIFF_LIBRARIES} llsm_tiff ${LLSM_EXT_LIBRARIES} )
92+ target_include_directories (llsm_importer PUBLIC ${LLSM_EXT_INCLUDE_DIRS} )
93+ else ()
94+ message (WARNING "LibTiff not found, ignore building the executables which requires LibTiff support." )
95+ endif ()
96+ endif ()
0 commit comments