forked from HPCE/hpce-2018-cw3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·129 lines (101 loc) · 5 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
## This was contributed by https://github.com/farrell236 in 2014.
## ==============================================================================
##
## CMake project settings
##
## ==============================================================================
## Name of the project handled by CMake
project (HPCE-2016-CW3)
## Minimum required version of CMake to configure the project
cmake_minimum_required (VERSION 2.8)
## Enforced CMake policy
cmake_policy (VERSION 2.8)
## ==============================================================================
##
## Configure Khronos OpenCL Libs
##
## ==============================================================================
set(OPENCL_SDK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/opencl_sdk/)
set(OPENCL_SDK_HEADERS ${OPENCL_SDK_DIR}/include/)
if(WIN32)
set(OPENCL_SDK_LIB ${OPENCL_SDK_DIR}/lib/windows/x86/OpenCL.lib)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(OPENCL_SDK_LIB ${OPENCL_SDK_DIR}/lib/windows/x86_64/OpenCL.lib)
endif()
elseif(CYGWIN)
set(OPENCL_SDK_LIB ${OPENCL_SDK_DIR}/lib/cygwin/x86/libOpenCL.a)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(OPENCL_SDK_LIB ${OPENCL_SDK_DIR}/lib/cygwin/x86_64/libOpenCL.a)
endif()
else()
# TODO : If it fails, you may need to add a new directory to the hint
#list for your system, or explicitly state where it is.
find_library(OPENCL_SDK_LIB NAMES OpenCL libOpenCL
HINTS /usr/lib/x86_64-linux-gnu /usr/local/lib /usr/lib/x86-linux-gnu
)
endif()
## ==============================================================================
##
## Configure Default Coursework Files
##
## ==============================================================================
set(COURSEWORK_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/)
set(HEAT_HPP ${CMAKE_CURRENT_SOURCE_DIR}/include/heat.hpp)
set(HEAT_CPP ${CMAKE_CURRENT_SOURCE_DIR}/src/heat.cpp)
include_directories(${COURSEWORK_HEADER} ${OPENCL_SDK_HEADERS})
add_executable(test_opencl ${HEAT_HPP} ${HEAT_CPP} ${CMAKE_CURRENT_SOURCE_DIR}/src/test_opencl.cpp)
add_executable(make_world ${HEAT_HPP} ${HEAT_CPP} ${CMAKE_CURRENT_SOURCE_DIR}/src/make_world.cpp)
add_executable(render_world ${HEAT_HPP} ${HEAT_CPP} ${CMAKE_CURRENT_SOURCE_DIR}/src/render_world.cpp)
add_executable(step_world ${HEAT_HPP} ${HEAT_CPP} ${CMAKE_CURRENT_SOURCE_DIR}/src/step_world.cpp)
target_link_libraries(test_opencl ${OPENCL_SDK_LIB})
target_link_libraries(make_world ${OPENCL_SDK_LIB})
target_link_libraries(render_world ${OPENCL_SDK_LIB})
target_link_libraries(step_world ${OPENCL_SDK_LIB})
## ==============================================================================
##
## Configure Additional Coursework Files
##
## ==============================================================================
## TODO : Change this param to your IC username
set(LOGIN_ID "<your_login>")
set(USR_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/${LOGIN_ID})
file(GLOB USR_SRC RELATIVE ${USR_SRC_DIR} ${USR_SRC_DIR}/*.cpp)
foreach(SRC_FILE ${USR_SRC})
string(REPLACE ".cpp" "" EXECUTABLE ${SRC_FILE})
add_executable(${EXECUTABLE} ${HEAT_HPP} ${HEAT_CPP} ${USR_SRC_DIR}/${SRC_FILE})
target_link_libraries(${EXECUTABLE} ${OPENCL_SDK_LIB})
endforeach(SRC_FILE ${USR_SRC})
## ==============================================================================
##
## Compiler Flags
##
## ==============================================================================
# As suggested by @hamish-milne
#set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wall -std=c++11 -o2")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wall -std=gnu++11 -o2")
## Get rid of DLL errors
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-static")
## ==============================================================================
##
## Configuration summary
##
## ==============================================================================
message (STATUS "------------------------------------------------------------" )
message (STATUS "[HPCE-2014-CW4] Configuration summary." )
message (STATUS "------------------------------------------------------------" )
message (STATUS " System configuration:" )
message (STATUS " .. Processor type ............. = ${CMAKE_SYSTEM_PROCESSOR}" )
message (STATUS " .. CMake executable ........... = ${CMAKE_COMMAND}" )
message (STATUS " .. CMake version .............. = ${CMAKE_VERSION}" )
message (STATUS " .. System name ................ = ${CMAKE_SYSTEM}" )
message (STATUS " .. C++ compiler ............... = ${CMAKE_CXX_COMPILER}" )
message (STATUS " .. C compiler ................. = ${CMAKE_C_COMPILER}" )
message (STATUS " .. size(void*) ................ = ${CMAKE_SIZEOF_VOID_P}" )
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/${LOGIN_ID})
message (STATUS " Additional Coursework Files:")
foreach( SRC_FILE ${USR_SRC} )
message (STATUS " .. ${SRC_FILE}")
endforeach( SRC_FILE ${USR_SRC} )
endif()
message (STATUS "------------------------------------------------------------" )