code_fodder
code_fodder

Reputation: 16391

Compile issues: LIBUSB_1 with cmake project on Windows

First Attempt

In my cmake/c++ project I get the following error when compiling:

C:\local\projects\synergy-usb\synergy-through-usb-master>cmake .
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBUSB_1_INCLUDE_DIR
   used as include directory in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/arch
   used as include directory in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/net
LIBUSB_1_LIBRARY
    linked by target "arch" in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/arch

-- Configuring incomplete, errors occurred!
See also "C:/local/projects/synergy-usb/synergy-through-usb-master/CMakeFiles/CMakeOutput.log".

So I am missing libusb libraries.

Second Attempt

So now I have found a version of libusb_1 (libusbx-1.0.18-win) which includes the folders:

I copied MS64/dll (windows 64-bit) contents and put it here:

C:\local\libs\libusbx

I added this path to my PATH variable and then tried to run cmake again:

C:>cd local\projects\synergy-usb\synergy-through-usb-master

C:\local\projects\synergy-usb\synergy-through-usb-master>cmake .
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBUSB_1_LIBRARY
    linked by target "arch" in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/arch

-- Configuring incomplete, errors occurred!
See also "C:/local/projects/synergy-usb/synergy-through-usb-master/CMakeFiles/CMakeOutput.log".

Now I am stuck again. I have no idea what it wants me to do. It knows where libusb is...

Edit

Here is the contects (part of) the CMakeLists.txt that has libusb in it:

find_package(libusb-1.0 REQUIRED)

set(inc
    .
    ../base
    ../common
    ../mt
    ../platform
    ../synergy
    ${LIBUSB_1_INCLUDE_DIRS}
)

if (UNIX)
    list(APPEND inc
        ../../..
        ../arch
    )
endif()

include_directories(${inc})
add_library(arch STATIC ${src})

set(libs
    ../lib
    ${LIBUSB_1_LIBRARIES}
    )

if (WIN32)
    if (GAME_DEVICE_SUPPORT)
        list(APPEND libs synxinhk)
    endif()
endif()

target_link_libraries(arch ${libs})

Edit 2

I added the following lines into the findlibusb-1.0.cmake file:

set(LIBUSB_1_LIBRARY C:\\local\\libs\\libusbx\\libusb-1.0.dll)
message(STATUS "***********************************>   LIBUSB_1_LIBRARY: ${LIBUSB_1_LIBRARY}")

Here is the output from that:

C:\local\projects\synergy-usb\synergy-through-usb-master>cmake .
-- ***********************************>   LIBUSB_1_LIBRARY: C:\local\libs\libusbx\libusb-1.0.dll
-- Found libusb-1.0:
--  - Includes: C:/local/libs/libusbx
--  - Libraries: C:\local\libs\libusbx\libusb-1.0.dll
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Configuring done
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
-- Generating done
-- Build files have been written to: C:/local/projects/synergy-usb/synergy-through-usb-master

Still does not build, but this particular library seems to be added ok now :)

Upvotes: 2

Views: 2862

Answers (1)

Serg Kryvonos
Serg Kryvonos

Reputation: 4677

synergy had such approach to keep some 3rd party libs compressed in zip in ext subdirectory. synergy-through-usb though kept cmake way to specify include through -DLIBUSB_1_INCLUDE_DIR=... -DLIBUSB_1_LIBRARY=... for Windows.

So you just need go to 'ext' directory and uncompress its zip archives with libraries gtest, gmock and crypto.

Upvotes: 1

Related Questions