source: CLRX/CLRadeonExtender/trunk/CMakeLists.txt @ 3891

Last change on this file since 3891 was 3891, checked in by matszpk, 16 months ago

CLRadeonExtender: Add info about building under FreeBSD. Add extra rpath when FreeBSD and gcc used.

  • Property svn:mime-type set to text/plain
File size: 16.3 KB
Line 
1####
2#  CLRadeonExtender - Unofficial OpenCL Radeon Extensions Library
3#  Copyright (C) 2014-2018 Mateusz Szpakowski
4#
5#  This library is free software; you can redistribute it and/or
6#  modify it under the terms of the GNU Lesser General Public
7#  License as published by the Free Software Foundation; either
8#  version 2.1 of the License, or (at your option) any later version.
9#
10#  This library is distributed in the hope that it will be useful,
11#  but WITHOUT ANY WARRANTY; without even the implied warranty of
12#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13#  Lesser General Public License for more details.
14#
15#  You should have received a copy of the GNU Lesser General Public
16#  License along with this library; if not, write to the Free Software
17#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18####
19
20CMAKE_MINIMUM_REQUIRED(VERSION 2.8.1)
21
22PROJECT(CLRadeonExtender)
23
24SET(CLRX_MAJOR_VERSION 0)
25SET(CLRX_MINOR_VERSION 1)
26SET(CLRX_MICRO_VERSION 7)
27SET(CLRX_VERSION ${CLRX_MAJOR_VERSION}.${CLRX_MINOR_VERSION}.${CLRX_MICRO_VERSION}${CLRX_VERSION_REVISION})
28SET(CLRX_LIB_VERSION ${CLRX_MAJOR_VERSION}.${CLRX_MINOR_VERSION}.${CLRX_MICRO_VERSION})
29
30ENABLE_LANGUAGE(CXX)
31
32SET(EXTRA_OPTS CACHE STRING "add extra options")
33SET(CPU_ARCH CACHE STRING "Set CPU architecture option")
34OPTION(GCC5CXX11NEWABI "Force new GCC 5 C++11 ABI" OFF)
35IF(GCC5CXX11NEWABI)
36    MESSAGE(STATUS "GCC5 C++11 New ABI enabled")
37    SET(EXTRA_PACK_SUFFIX "-gcc5")
38ENDIF(GCC5CXX11NEWABI)
39
40#####
41# packacing
42SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Unofficial OpenCL Radeon extensions")
43SET(CPACK_PACKAGE_VENDOR "matszpk")
44SET(CPACK_PACKAGE_MAINTAINER "matszpk")
45SET(CPACK_PACKAGE_VERSION_MAJOR ${CLRX_MAJOR_VERSION})
46SET(CPACK_PACKAGE_VERSION_MINOR ${CLRX_MINOR_VERSION})
47SET(CPACK_PACKAGE_VERSION_PATCH ${CLRX_MICRO_VERSION})
48SET(CPACK_PACKAGE_VERSION ${CLRX_VERSION})
49SET(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
50IF((CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_CL_64) AND NOT BUILD_32BIT)
51SET(CPACK_PACKAGE_FILE_NAME CLRadeonExtender-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}-x64${EXTRA_PACK_SUFFIX})
52ELSE((CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_CL_64) AND NOT BUILD_32BIT)
53SET(CPACK_PACKAGE_FILE_NAME CLRadeonExtender-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}-x86${EXTRA_PACK_SUFFIX})
54ENDIF((CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_CL_64) AND NOT BUILD_32BIT)
55
56INCLUDE(CPack)
57
58######
59## end packaging
60
61LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
62
63INCLUDE(CheckFunctionExists)
64INCLUDE(CheckLibraryExists)
65INCLUDE(CheckIncludeFileCXX)
66INCLUDE(CheckCCompilerFlag)
67INCLUDE(CheckCXXCompilerFlag)
68
69CHECK_CXX_COMPILER_FLAG("-std=gnu++11" HAVE_GNU11_FLAG)
70
71# workaround for
72SET(CMAKE_REQUIRED_FLAGS "-std=gnu++11")
73CHECK_INCLUDE_FILE_CXX(iostream HAVE_GNU11_IOSTREAM)
74UNSET(CMAKE_REQUIRED_FLAGS)
75
76IF(HAVE_GNU11_FLAG AND HAVE_GNU11_IOSTREAM)
77    SET(CPP_STANDARD "-std=gnu++11")
78    SET(HAVE_GNU11 1)
79ELSE(HAVE_GNU11_FLAG AND HAVE_GNU11_IOSTREAM)
80    SET(CPP_STANDARD "-std=c++11")
81ENDIF(HAVE_GNU11_FLAG AND HAVE_GNU11_IOSTREAM)
82
83MESSAGE(STATUS "Use standard ${CPP_STANDARD} for ${CMAKE_CXX_COMPILER}")
84
85IF(GCC5CXX11NEWABI)
86    ADD_DEFINITIONS(-D_GLIBCXX_USE_CXX11_ABI=1)
87ENDIF(GCC5CXX11NEWABI)
88
89### 32-bit compilation option
90OPTION(BUILD_32BIT "Build 32-bit version" OFF)
91
92IF(CPU_ARCH)
93    IF(MSVC)
94        SET(EXTRA_OPTS "${EXTRA_OPTS} /arch:${CPU_ARCH}")
95    ELSE(MSVC)
96        SET(EXTRA_OPTS "${EXTRA_OPTS} -march=${CPU_ARCH}")
97    ENDIF(MSVC)
98ENDIF(CPU_ARCH)
99
100IF(BUILD_32BIT)
101    SET(CMAKE_CXX_FLAGS "-Wall -m32 ${EXTRA_OPTS} ${CPP_STANDARD}")
102    SET(CMAKE_CXX_FLAGS_DEBUG "-Wall -m32 ${EXTRA_OPTS} ${CPP_STANDARD} -g -O0 -DDEBUG=1")
103    SET(CMAKE_CXX_FLAGS_DEBUGCOV
104        "-Wall -m32 ${EXTRA_OPTS} ${CPP_STANDARD} -g -O0 -DDEBUG=1 --coverage")
105    SET(CMAKE_CXX_FLAGS_GCCSAN
106    "-Wall -m32 ${EXTRA_OPTS} ${CPP_STANDARD} -g -O0 -DDEBUG=1 -fstack-protector-all -fsanitize=address")
107    SET(CMAKE_CXX_FLAGS_GCCSSP
108        "-Wall -m32 ${EXTRA_OPTS} ${CPP_STANDARD} -g -O0 -DDEBUG=1 -fstack-protector-all")
109    SET(CMAKE_CXX_FLAGS_RELEASE
110        "-Wall -m32 ${EXTRA_OPTS} ${CPP_STANDARD} -O2 -fomit-frame-pointer")
111    SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
112        "-Wall -m32 ${EXTRA_OPTS} ${CPP_STANDARD} -g -O2 -funroll-loops -DDEBUG=1")
113    SET(CMAKE_CXX_FLAGS_RELWITHPROFILE
114        "-Wall -m32 ${EXTRA_OPTS} ${CPP_STANDARD} -g -O2 -pg -funroll-loops")
115ELSE(BUILD_32BIT)
116    IF(MSVC)
117    SET(CMAKE_CXX_FLAGS "/W1 ${EXTRA_OPTS} /EHsc")
118    SET(CMAKE_CXX_FLAGS_DEBUG "/W1 ${EXTRA_OPTS} /EHsc /Zi /Od /DDEBUG=1")
119    SET(CMAKE_CXX_FLAGS_RELEASE "/W1 ${EXTRA_OPTS} /EHsc /O2")
120    SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/W1 ${EXTRA_OPTS} /EHsc /Zi /O2 /DDEBUG=1")
121    ELSE(MSVC)
122    SET(CMAKE_CXX_FLAGS "-Wall ${EXTRA_OPTS} ${CPP_STANDARD}")
123    SET(CMAKE_CXX_FLAGS_DEBUG "-Wall ${EXTRA_OPTS} ${CPP_STANDARD} -g -O0 -DDEBUG=1")
124    SET(CMAKE_CXX_FLAGS_DEBUGCOV
125        "-Wall ${EXTRA_OPTS} ${CPP_STANDARD} -g -O0 -DDEBUG=1 --coverage")
126    SET(CMAKE_CXX_FLAGS_GCCSAN
127        "-Wall ${EXTRA_OPTS} ${CPP_STANDARD} -g -O0 -DDEBUG=1 -fstack-protector-all -fsanitize=address")
128    SET(CMAKE_CXX_FLAGS_GCCSSP
129        "-Wall ${EXTRA_OPTS} ${CPP_STANDARD} -g -O0 -DDEBUG=1 -fstack-protector-all")
130    SET(CMAKE_CXX_FLAGS_RELEASE
131        "-Wall ${EXTRA_OPTS} ${CPP_STANDARD} -O2 -fomit-frame-pointer")
132    SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
133        "-Wall ${EXTRA_OPTS} ${CPP_STANDARD} -g -O2 -funroll-loops -DDEBUG=1")
134    SET(CMAKE_CXX_FLAGS_RELWITHPROFILE
135        "-Wall ${EXTRA_OPTS} ${CPP_STANDARD} -g -O2 -pg -funroll-loops")
136    ENDIF(MSVC)
137ENDIF(BUILD_32BIT)
138
139# FreeBSD support
140STRING(REGEX MATCH "g\\+\\+[0-9]*$" CXX_COMPILER_IS_GCC "${CMAKE_CXX_COMPILER}")
141IF("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD" AND CXX_COMPILER_IS_GCC)
142    IF("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "5.0.0")
143        STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1\\2" RPATH_GCC_VER
144                "${CMAKE_CXX_COMPILER_VERSION}")
145    ELSE("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "5.0.0")
146        STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" RPATH_GCC_VER
147                "${CMAKE_CXX_COMPILER_VERSION}")
148    ENDIF("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "5.0.0")
149   
150    SET(GCC_RPATH "/usr/local/lib/gcc${RPATH_GCC_VER}")
151    MESSAGE(STATUS "Add extra rpath ${GCC_RPATH}")
152   
153    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-rpath=${GCC_RPATH}")
154    SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wl,-rpath=${GCC_RPATH}")
155    SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wl,-rpath=${GCC_RPATH}")
156    SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
157            "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -Wl,-rpath=${GCC_RPATH}")
158    SET(CMAKE_CXX_FLAGS_DEBUGCOV "${CMAKE_CXX_FLAGS_DEBUGCOV} -Wl,-rpath=${GCC_RPATH}")
159    SET(CMAKE_CXX_FLAGS_GCCSAN "${CMAKE_CXX_FLAGS_GCCSAN} -Wl,-rpath=${GCC_RPATH}")
160    SET(CMAKE_CXX_FLAGS_GCCSSP "${CMAKE_CXX_FLAGS_GCCSSP} -Wl,-rpath=${GCC_RPATH}")
161ENDIF("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD" AND CXX_COMPILER_IS_GCC)
162
163# check system bitness
164TRY_COMPILE(HAVE_64BIT "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/Check64Bit.cpp")
165IF(HAVE_64BIT)
166    MESSAGE(STATUS "Compile for 64-bit system")
167ELSE(HAVE_64BIT)
168    MESSAGE(STATUS "Compile for 32-bit system")
169ENDIF(HAVE_64BIT)
170
171# determine library directory name
172IF(NOT LIB_INSTALL_DIR)
173    IF(HAVE_64BIT AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
174        SET(LIB_INSTALL_DIR "lib64")
175    ELSE(HAVE_64BIT AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
176        SET(LIB_INSTALL_DIR "lib")
177    ENDIF(HAVE_64BIT AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
178    MESSAGE(STATUS "Using library install dirname ${LIB_INSTALL_DIR}")
179ENDIF(NOT LIB_INSTALL_DIR)
180
181IF(IS_DIRECTORY "/usr/lib/x86_64-linux-gnu/amdgpu-pro" OR
182    IS_DIRECTORY "/usr/lib/i386-linux-gnu/amdgpu-pro")
183    SET(HAVE_UBUNTU_GPUPRO TRUE)
184    MESSAGE(STATUS "AMDGPU-PRO for Ubuntu is found")
185ENDIF(IS_DIRECTORY "/usr/lib/x86_64-linux-gnu/amdgpu-pro" OR
186    IS_DIRECTORY "/usr/lib/i386-linux-gnu/amdgpu-pro")
187IF(IS_DIRECTORY "/opt/amdgpu-pro/lib/x86_64-linux-gnu" OR
188        IS_DIRECTORY "/opt/amdgpu-pro/lib/i386-linux-gnu")
189    SET(HAVE_GPUPRO_NEW TRUE)
190    MESSAGE(STATUS "New AMDGPU-PRO is found")
191ENDIF(IS_DIRECTORY "/opt/amdgpu-pro/lib/x86_64-linux-gnu" OR
192        IS_DIRECTORY "/opt/amdgpu-pro/lib/i386-linux-gnu")
193IF (NOT HAVE_GPUPRO_NEW AND NOT HAVE_UBUNTU_GPUPRO)
194    IF(IS_DIRECTORY "/opt/amdgpu-pro/lib64" OR IS_DIRECTORY "/opt/amdgpu-pro/lib")
195        SET(HAVE_GPUPRO_SLES TRUE)
196        MESSAGE(STATUS "SLES AMDGPU-PRO is found")
197    ENDIF(IS_DIRECTORY "/opt/amdgpu-pro/lib64" OR IS_DIRECTORY "/opt/amdgpu-pro/lib")
198ENDIF(NOT HAVE_GPUPRO_NEW AND NOT HAVE_UBUNTU_GPUPRO)
199
200IF("${PROJECT_SOURCE_DIR}" MATCHES "${PROJECT_BINARY_DIR}")
201    MESSAGE("Please do an out-of-tree build:")
202    MESSAGE("rm -f CMakeCache.txt; mkdir -p default; cd default; cmake ..; make")
203    MESSAGE(FATAL_ERROR "in-tree-build detected")
204ENDIF("${PROJECT_SOURCE_DIR}" MATCHES "${PROJECT_BINARY_DIR}")
205
206SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
207SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
208
209OPTION(NO_STATIC "Disable static during compiling" OFF)
210
211INCLUDE(PortUtils)
212IF(WIN32)
213  SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
214ENDIF(WIN32)
215
216####
217# Documentation
218####
219OPTION(BUILD_DOCUMENTATION "Build whole documentation" OFF)
220OPTION(BUILD_DOXYGEN "Use Doxygen to create the HTML based API documentation" OFF)
221OPTION(BUILD_MANUAL "Use Pod2Man to create the Unix manuals" OFF)
222OPTION(BUILD_CLRXDOC "Use markdown_py to create offline wiki pages" OFF)
223
224IF(BUILD_DOCUMENTATION)
225  SET(BUILD_DOXYGEN ON)
226  SET(BUILD_MANUAL ON)
227  SET(BUILD_CLRXDOC ON)
228ENDIF(BUILD_DOCUMENTATION)
229
230####
231# rules to build doxygen and clrx doc is in proper CMakeLists.txt files in subdirectories
232####
233
234IF(BUILD_MANUAL)
235    INCLUDE(Pod2Man)
236    ADD_MANPAGE_TARGET()
237ENDIF(BUILD_MANUAL)
238####
239# Documentation
240####
241
242INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}")
243INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
244
245OPTION(NO_OPENCL "Do not use OpenCL" OFF)
246OPTION(NO_CLWRAPPER "Do not enable CLRXWrapper" OFF)
247
248####
249# OpenCL find
250####
251SET(OPENCL_DIST_DIR "" CACHE PATH "OpenCL Distribution directory")
252
253IF(NOT OPENCL_DIST_DIR AND NOT NO_OPENCL)
254    IF(EXISTS /opt/AMDAPP)
255        SET(OPENCL_DIST_DIR "/opt/AMDAPP")
256        MESSAGE(STATUS "OpenCL AMDAPP found")
257    ELSEIF(EXISTS "/Program Files (x86)/AMD APP SDK")
258        FILE(GLOB OPENCL_DIST_DIR "/Program Files (x86)/AMD APP SDK/*")
259        MESSAGE(STATUS "OpenCL AMDAPP found")
260    ELSEIF(EXISTS "/Program Files/AMD APP SDK")
261        FILE(GLOB OPENCL_DIST_DIR "/Program Files/AMD APP SDK/*")
262        MESSAGE(STATUS "OpenCL AMDAPP found")
263    ELSEIF(EXISTS /usr/include/CL)
264        SET(OPENCL_DIST_DIR "/usr")
265        MESSAGE(STATUS "Standard OpenCL found.")
266    ENDIF(EXISTS /opt/AMDAPP)
267ENDIF(NOT OPENCL_DIST_DIR AND NOT NO_OPENCL)
268
269IF (NOT NO_OPENCL AND OPENCL_DIST_DIR)
270    SET(OPENCL_LIBRARY_DIRS "")
271    SET(OPENCL_INCLUDE_DIRS "${OPENCL_DIST_DIR}/include")
272    SET(OPENCL_LIBRARIES "OpenCL")
273    SET(HAVE_OPENCL 1)
274ENDIF(NOT NO_OPENCL AND OPENCL_DIST_DIR)
275
276# check for AMDAPP lib/x86 or lib/x86_64 libOpenCL.so file
277IF(HAVE_OPENCL)
278    IF(HAVE_64BIT)
279        IF(EXISTS ${OPENCL_DIST_DIR}/lib/x86_64/libOpenCL.so OR
280            EXISTS ${OPENCL_DIST_DIR}/lib/x86_64/OpenCL.lib)
281            SET(OPENCL_LIBRARY_DIRS "${OPENCL_DIST_DIR}/lib/x86_64")
282        ENDIF(EXISTS ${OPENCL_DIST_DIR}/lib/x86_64/libOpenCL.so OR
283            EXISTS ${OPENCL_DIST_DIR}/lib/x86_64/OpenCL.lib)
284    ELSE(HAVE_64BIT)
285        IF(EXISTS ${OPENCL_DIST_DIR}/lib/x86/libOpenCL.so OR
286            EXISTS ${OPENCL_DIST_DIR}/lib/x86/OpenCL.lib)
287            SET(OPENCL_LIBRARY_DIRS "${OPENCL_DIST_DIR}/lib/x86")
288        ENDIF(EXISTS ${OPENCL_DIST_DIR}/lib/x86/libOpenCL.so OR
289            EXISTS ${OPENCL_DIST_DIR}/lib/x86/OpenCL.lib)
290    ENDIF(HAVE_64BIT)
291    IF(HAVE_UBUNTU_GPUPRO)
292        IF(HAVE_64BIT)
293            SET(OPENCL_LIBRARY_DIRS "/usr/lib/x86_64-linux-gnu/amdgpu-pro")
294        ELSE(HAVE_64BIT)
295            SET(OPENCL_LIBRARY_DIRS "/usr/lib/i386-linux-gnu/amdgpu-pro")
296        ENDIF(HAVE_64BIT)
297    ENDIF(HAVE_UBUNTU_GPUPRO)
298    IF(HAVE_GPUPRO_NEW)
299        IF(HAVE_64BIT)
300            SET(OPENCL_LIBRARY_DIRS "/opt/amdgpu-pro/lib/x86_64-linux-gnu")
301        ELSE(HAVE_64BIT)
302            SET(OPENCL_LIBRARY_DIRS "/opt/amdgpu-pro/lib/i386-linux-gnu")
303        ENDIF(HAVE_64BIT)
304    ENDIF(HAVE_GPUPRO_NEW)
305    IF(HAVE_GPUPRO_SLES)
306        IF(HAVE_64BIT)
307            SET(OPENCL_LIBRARY_DIRS "/opt/amdgpu-pro/lib64")
308        ELSE(HAVE_64BIT)
309            SET(OPENCL_LIBRARY_DIRS "/opt/amdgpu-pro/lib")
310        ENDIF(HAVE_64BIT)
311    ENDIF(HAVE_GPUPRO_SLES)
312ENDIF(HAVE_OPENCL)
313
314###
315# end of OpenCL config
316###
317
318IF(HAVE_OPENCL)
319    MESSAGE(STATUS "OpenCL found")
320    MESSAGE(STATUS "OpenCL library dirs: " ${OPENCL_LIBRARY_DIRS})
321    MESSAGE(STATUS "OpenCL libraries: " ${OPENCL_LIBRARIES})
322    MESSAGE(STATUS "OpenCL include dirs: " ${OPENCL_INCLUDE_DIRS})
323ELSE(HAVE_OPENCL)
324    MESSAGE(STATUS "OpenCL not found")
325ENDIF(HAVE_OPENCL)
326
327## OpenGL finding
328
329IF(NOT NO_CLWRAPPER)
330    FIND_PACKAGE(OpenGL)
331    IF(OPENGL_INCLUDE_DIR)
332        FIND_PATH(HAVE_OPENGL GL/gl.h PATHS "${OPENGL_INCLUDE_DIR}")
333    ELSE(OPENGL_INCLUDE_DIR)
334        SET(OPENGL_INCLUDE_DIR "")
335    ENDIF(OPENGL_INCLUDE_DIR)
336    # check GL/gl.h even if OpenGL is not detected (library is not needed)
337    IF(HAVE_OPENGL)
338        MESSAGE(STATUS "OpenGL found")
339        MESSAGE(STATUS "OpenGL include dirs: " ${OPENGL_INCLUDE_DIR})
340    ELSE(HAVE_OPENGL)
341        MESSAGE(STATUS "OpenGL not found")
342    ENDIF(HAVE_OPENGL)
343ENDIF(NOT NO_CLWRAPPER)
344
345SET(CMAKE_THREAD_PREFER_PTHREAD 1)
346FIND_PACKAGE(Threads)
347
348TRY_COMPILE(HAVE_INT128 "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/Int128Detect.cpp")
349TRY_COMPILE(HAVE_CALL_ONCE "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/ThreadOnce.cpp")
350
351IF(HAVE_INT128)
352    MESSAGE(STATUS "128-bit integer arithmetic detected")
353ELSE(HAVE_INT128)
354    MESSAGE(STATUS "128-bit integer arithmetic not supported by compiler")
355ENDIF(HAVE_INT128)
356
357IF(HAVE_CALL_ONCE)
358    MESSAGE(STATUS "Environment have C++11 std::call_once")
359ELSE(HAVE_CALL_ONCE)
360    MESSAGE(STATUS "Environment have no C++11 std::call_once")
361ENDIF(HAVE_CALL_ONCE)
362
363###
364# other dependencies and checks
365###
366
367FIND_PACKAGE(PNG)
368
369IF(PNG_FOUND)
370    MESSAGE(STATUS "Png found ${PNG_INCLUDE_DIRS}")
371ENDIF(PNG_FOUND)
372
373###
374# end of other dependencies and checks
375###
376
377IF(NOT WIN32)
378    SET(MATHLIB "m")
379ENDIF(NOT WIN32)
380
381CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/CLRX/Config.h.in"
382        "${PROJECT_BINARY_DIR}/CLRX/Config.h")
383
384OPTION(BUILD_TESTS "Compile tests" OFF)
385OPTION(BUILD_SAMPLES "Compile samples" OFF)
386OPTION(BUILD_STATIC_EXE "Compile static executables instead shared" OFF)
387
388# fixing CMAKE_DL_LIBS
389IF(CMAKE_DL_LIBS)
390    IF(CMAKE_DL_LIBS MATCHES "^-l")
391        SET(DL_LIBS "${CMAKE_DL_LIBS}")
392    ELSE(CMAKE_DL_LIBS MATCHES "^-l")
393        SET(DL_LIBS "-l${CMAKE_DL_LIBS}")
394    ENDIF(CMAKE_DL_LIBS MATCHES "^-l")
395ELSE(CMAKE_DL_LIBS)
396    SET(DL_LIBS "")
397ENDIF(CMAKE_DL_LIBS)
398
399IF(BUILD_STATIC_EXE)
400    SET(PROGRAM_LIB_SUFFIX "Static")
401ELSE(BUILD_STATIC_EXE)
402    SET(PROGRAM_LIB_SUFFIX "")
403ENDIF(BUILD_STATIC_EXE)
404
405IF(BUILD_TESTS)
406    ENABLE_TESTING()
407ENDIF(BUILD_TESTS)
408
409INCLUDE_DIRECTORIES(${OPENCL_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR})
410
411LINK_DIRECTORIES("${OPENCL_LIBRARY_DIRS}")
412
413ADD_SUBDIRECTORY(CLRX)
414ADD_SUBDIRECTORY(utils)
415IF(HAVE_OPENCL AND NOT NO_CLWRAPPER)
416    ADD_SUBDIRECTORY(clwrapper)
417ENDIF(HAVE_OPENCL AND NOT NO_CLWRAPPER)
418ADD_SUBDIRECTORY(amdbin)
419ADD_SUBDIRECTORY(amdasm)
420IF(HAVE_OPENCL)
421    ADD_SUBDIRECTORY(clhelper)
422ENDIF(HAVE_OPENCL)
423IF (BUILD_TESTS)
424    ADD_SUBDIRECTORY(tests)
425ENDIF(BUILD_TESTS)
426
427ADD_SUBDIRECTORY(editors)
428ADD_SUBDIRECTORY(programs)
429IF (BUILD_SAMPLES AND HAVE_OPENCL)
430    ADD_SUBDIRECTORY(samples)
431ENDIF(BUILD_SAMPLES AND HAVE_OPENCL)
432
433ADD_SUBDIRECTORY(doc)
434
435ADD_SUBDIRECTORY(pkgconfig)
436
437SET(DOCINSTALLDIR share/doc/CLRX)
438INSTALL(FILES "${PROJECT_SOURCE_DIR}/AUTHORS" DESTINATION "${DOCINSTALLDIR}")
439INSTALL(FILES "${PROJECT_SOURCE_DIR}/CONTRIBUTORS" DESTINATION "${DOCINSTALLDIR}")
440INSTALL(FILES "${PROJECT_SOURCE_DIR}/COPYING" DESTINATION "${DOCINSTALLDIR}")
441INSTALL(FILES "${PROJECT_SOURCE_DIR}/ChangeLog" DESTINATION "${DOCINSTALLDIR}")
442INSTALL(FILES "${PROJECT_SOURCE_DIR}/COPYING.LIB" DESTINATION "${DOCINSTALLDIR}")
443INSTALL(FILES "${PROJECT_SOURCE_DIR}/COPYING.DOC" DESTINATION "${DOCINSTALLDIR}")
444INSTALL(FILES "${PROJECT_SOURCE_DIR}/INSTALL" DESTINATION "${DOCINSTALLDIR}")
445INSTALL(FILES "${PROJECT_SOURCE_DIR}/README" DESTINATION "${DOCINSTALLDIR}")
446INSTALL(FILES "${PROJECT_SOURCE_DIR}/README.md" DESTINATION "${DOCINSTALLDIR}")
Note: See TracBrowser for help on using the repository browser.