etaler / Etaler

A flexable HTM (Hierarchical Temporal Memory) framework with full GPU support.
BSD 3-Clause "New" or "Revised" License
89 stars 14 forks source link

not enable to compile with openCL #109

Closed Thanh-Binh closed 4 years ago

Thanh-Binh commented 4 years ago

Hi Martin, by compiling cmake .. -DETALER_ENABLE_OPENCL=ON

I always have the following errors (because Catch2 is header file only, I do not understand why do you want to link???)

%] Linking CXX executable etaler_tests_opencl /usr/bin/ld.gold: error: cannot find -lCatch2::Catch2 collect2: error: ld returned 1 exit status tests/CMakeFiles/etaler_tests.dir/build.make:122: recipe for target 'tests/etaler_tests' failed make[2]: [tests/etaler_tests] Error 1 CMakeFiles/Makefile2:429: recipe for target 'tests/CMakeFiles/etaler_tests.dir/all' failed make[1]: [tests/CMakeFiles/etaler_tests.dir/all] Error 2 make[1]: Waiting for unfinished jobs.... /usr/bin/ld.gold: error: cannot find -lCatch2::Catch2 collect2: error: ld returned 1 exit status tests/CMakeFiles/etaler_tests_opencl.dir/build.make:122: recipe for target 'tests/etaler_tests_opencl' failed make[2]: [tests/etaler_tests_opencl] Error 1 CMakeFiles/Makefile2:392: recipe for target 'tests/CMakeFiles/etaler_tests_opencl.dir/all' failed make[1]: [tests/CMakeFiles/etaler_tests_opencl.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: [all] Error 2

marty1885 commented 4 years ago

@Thanh-Binh Thanks for reporting the issue.

I don't know why CMake is trying to link against Catch2. CMake should discover that the Catch2::Catch2 target is actually a virtual target that only provides interface information.

Which version of CMake are you using and how is your Catch2 installed?


As an temporary solution. Please change test/CMakeLists.txt to

project(etaler_tests CXX)
include_directories(/path/to/catch2/install)

add_executable(etaler_tests common_tests.cpp main.cpp)
target_link_libraries(etaler_tests Etaler)

if(ETALER_ENABLE_OPENCL)
    project(etaler_tests_opencl CXX)
    add_executable(etaler_tests_opencl common_tests.cpp main_opencl.cpp)
    target_link_libraries(etaler_tests_opencl Etaler)
endif()
Thanh-Binh commented 4 years ago

@marty1885 it works well with this Cmakefile. I can understand this problem. Because your SW uses only Catch.hpp so that I copy it directly to your test folder (as in your README). Commonly, we do NOT need to link to Catch2.... Thanks

marty1885 commented 4 years ago

fixes in #111