CMakeLists.txt 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. # A custom command and target to turn the OpenCL kernel into a byte array header
  2. # The normal build depends on it properly and if the kernel file is changed, then
  3. # a rebuild of libethash-cl should be triggered
  4. add_custom_command(
  5. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ethash_cl_miner_kernel.h
  6. COMMAND ${CMAKE_COMMAND} ARGS
  7. -DBIN2H_SOURCE_FILE="${CMAKE_CURRENT_SOURCE_DIR}/ethash_cl_miner_kernel.cl"
  8. -DBIN2H_VARIABLE_NAME=ethash_cl_miner_kernel
  9. -DBIN2H_HEADER_FILE="${CMAKE_CURRENT_BINARY_DIR}/ethash_cl_miner_kernel.h"
  10. -P "${CMAKE_CURRENT_SOURCE_DIR}/bin2h.cmake"
  11. COMMENT "Generating OpenCL Kernel Byte Array"
  12. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ethash_cl_miner_kernel.cl
  13. )
  14. add_custom_target(clbin2h DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ethash_cl_miner_kernel.h ${CMAKE_CURRENT_SOURCE_DIR}/ethash_cl_miner_kernel.cl)
  15. aux_source_directory(. SRC_LIST)
  16. file(GLOB OUR_HEADERS "*.h")
  17. set(HEADERS ${OUR_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/ethash_cl_miner_kernel.h)
  18. # TODO: Should fix properly. Cmake >= 3.4.0 detects a self linking of ethash-cl library here.
  19. cmake_policy(SET CMP0038 OLD)
  20. add_library(ethash-cl ${SRC_LIST} ${HEADERS})
  21. eth_use(ethash-cl REQUIRED OpenCL)
  22. find_package(Eth)
  23. target_include_directories(ethash-cl PRIVATE ..)
  24. target_include_directories(ethash-cl PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
  25. target_link_libraries(ethash-cl ${Eth_ETHASH_LIBRARIES})
  26. install(TARGETS ethash-cl RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)