From 63730439b81fe85e59ac218cfbe19ab8b912d9e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 15 Jul 2015 23:53:12 +0200 Subject: [PATCH] Disable OpenCL_ICD on OSX. --- CMakeLists.txt | 15 +++++++++++---- exp/CMakeLists.txt | 2 +- libethash-cl/CMakeLists.txt | 3 +-- libethash-cl/ethash_cl_miner.cpp | 6 ++++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ffe98617e..55aff81e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,7 +131,7 @@ function(createBuildInfo) add_custom_target(BuildInfo.h ALL WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${CMAKE_COMMAND} -DETH_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -DETH_DST_DIR="${CMAKE_BINARY_DIR}" - -DETH_BUILD_TYPE="${_cmake_build_type}" -DETH_BUILD_PLATFORM="${ETH_BUILD_PLATFORM}" + -DETH_BUILD_TYPE="${_cmake_build_type}" -DETH_BUILD_PLATFORM="${ETH_BUILD_PLATFORM}" -P "${ETH_SCRIPTS_DIR}/buildinfo.cmake" ) include_directories(${CMAKE_CURRENT_BINARY_DIR}) @@ -175,9 +175,9 @@ endif () macro(eth_format_option O) if (${${O}}) - set(${O} ON) + set(${O} ON) else() - set(${O} OFF) + set(${O} OFF) endif() endmacro() @@ -426,7 +426,14 @@ if (GENERAL OR MINER) add_subdirectory(libethash) if (ETHASHCL) add_subdirectory(libethash-cl) - add_subdirectory(khronos_icd) + if (APPLE) + add_library(OpenCL SHARED IMPORTED) + set_property(TARGET OpenCL PROPERTY IMPORTED_LOCATION ${OpenCL_LIBRARY}) + set(OpenCL_TARGET OpenCL) + else() + add_subdirectory(khronos_icd) + set(OpenCL_TARGET OpenCL_ICD) + endif() endif () endif () diff --git a/exp/CMakeLists.txt b/exp/CMakeLists.txt index 41940beef..b0e7a9951 100644 --- a/exp/CMakeLists.txt +++ b/exp/CMakeLists.txt @@ -27,6 +27,6 @@ target_link_libraries(${EXECUTABLE} p2p) if (ETHASHCL) target_link_libraries(${EXECUTABLE} ethash-cl) target_link_libraries(${EXECUTABLE} ethash) - target_link_libraries(${EXECUTABLE} OpenCL_ICD) + target_link_libraries(${EXECUTABLE} ${OpenCL_TARGET}) endif() install( TARGETS ${EXECUTABLE} DESTINATION bin) diff --git a/libethash-cl/CMakeLists.txt b/libethash-cl/CMakeLists.txt index 70f711a76..8688648bd 100644 --- a/libethash-cl/CMakeLists.txt +++ b/libethash-cl/CMakeLists.txt @@ -23,8 +23,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${Boost_INCLUDE_DIRS}) include_directories(..) add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) -TARGET_LINK_LIBRARIES(${EXECUTABLE} OpenCL_ICD ethash) +TARGET_LINK_LIBRARIES(${EXECUTABLE} ${OpenCL_TARGET} ethash) install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) - diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index 35700767c..3cdb12125 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -87,9 +87,11 @@ std::vector ethash_cl_miner::getPlatforms() } catch(cl::Error const& err) { + #if !defined(CL_PLATFORM_NOT_FOUND_KHR) if (err.err() == CL_PLATFORM_NOT_FOUND_KHR) ETHCL_LOG("No OpenCL platforms found"); else + #endif throw err; } return platforms; @@ -190,7 +192,7 @@ bool ethash_cl_miner::configureGPU( ); return true; } - + ETHCL_LOG( "OpenCL device " << _device.getInfo() << " has insufficient GPU memory." << result << @@ -231,7 +233,7 @@ bool ethash_cl_miner::searchForAllDevices(unsigned _platformId, function