Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile issue when used as submodule #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ if (NOT CMAKE_BUILD_TYPE)
"Options are Debug Release RelWithDebInfo MinSizeRel" FORCE)
endif ()

option (BUILD_SHARED_LIBS "Build as shared library" TRUE)
if (NOT BUILD_SHARED_LIBS)
option (BUILD_LIBUSBP_SHARED_LIBS "Build as shared library" ON)
if (NOT BUILD_LIBUSBP_SHARED_LIBS)
add_definitions (-DLIBUSBP_STATIC)
set (PC_MORE_CFLAGS "-DLIBUSBP_STATIC")
endif ()
Expand Down
16 changes: 10 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,34 @@ elseif (APPLE)
mac/iokit_mac.c)
endif ()

add_library (usbp ${sources})
if (BUILD_LIBUSBP_SHARED_LIBS)
add_library (usbp SHARED ${sources})
else ()
add_library (usbp STATIC ${sources})
endif ()

include_directories (
"${CMAKE_SOURCE_DIR}/include"
target_include_directories (usbp PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/../include"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}"
)

if (WIN32)
target_link_libraries (usbp setupapi winusb uuid ole32)
if (NOT BUILD_SHARED_LIBS)
if (NOT BUILD_LIBUSBP_SHARED_LIBS)
set (PC_MORE_LIBS "-lsetupapi -lwinusb -luuid -lole32")
endif ()
elseif (LINUX)
pkg_check_modules(LIBUDEV REQUIRED libudev)
string (REPLACE ";" " " LIBUDEV_CFLAGS "${LIBUDEV_CFLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUDEV_CFLAGS}")
target_link_libraries (usbp udev)
if (NOT BUILD_SHARED_LIBS)
if (NOT BUILD_LIBUSBP_SHARED_LIBS)
set (PC_REQUIRES "libudev")
endif ()
elseif (APPLE)
set (link_flags "-framework IOKit -framework CoreFoundation ${link_flags}")
if (NOT BUILD_SHARED_LIBS)
if (NOT BUILD_LIBUSBP_SHARED_LIBS)
set (PC_MORE_LIBS "${link_flags}")
endif ()
endif ()
Expand Down