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

Add option to not install static lib #11

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
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if [ "$1" == "--help" ]; then
echo "to CMake by this script. For example:"
echo " ./configure -D CMAKE_INSTALL_PREFIX=/usr "
echo " ./configure -D CMAKE_BUILD_TYPE=Release "
echo " ./configure -D BUILD_STATIC_LIBS=OFF "
echo " ./configure -D LIB_SUFFIX=64 "
echo "Passing no parameters will give the default build."
exit 1
Expand Down
27 changes: 18 additions & 9 deletions piehid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ if(DEFINED LIBDIRSUFFIX)
set(LIB_SUFFIX ${LIBDIRSUFFIX})
endif(DEFINED LIBDIRSUFFIX)

OPTION(BUILD_STATIC_LIBS "Build static library" ON)

# Link against libusb and pthreads.
find_package(PkgConfig)
PKG_CHECK_MODULES(LIBUSB REQUIRED libusb-1.0)
Expand All @@ -38,12 +40,12 @@ LINK_DIRECTORIES(

ADD_DEFINITIONS()

#ADD_EXECUTABLE(test ${SRCS})
ADD_LIBRARY(piehid SHARED ${SRCS})
ADD_LIBRARY(piehid_static STATIC ${SRCS})
SET_TARGET_PROPERTIES(piehid_static PROPERTIES OUTPUT_NAME piehid)
IF(BUILD_STATIC_LIBS)
ADD_LIBRARY(piehid_static STATIC ${SRCS})
SET_TARGET_PROPERTIES(piehid_static PROPERTIES OUTPUT_NAME piehid)
ENDIF (BUILD_STATIC_LIBS)
SET_TARGET_PROPERTIES(piehid PROPERTIES PUBLIC_HEADER PieHid32.h)
#SET_TARGET_PROPERTIES(piehid PROPERTIES VERSION 1)
SET_TARGET_PROPERTIES(piehid PROPERTIES SOVERSION 1)

TARGET_LINK_LIBRARIES(
Expand All @@ -52,10 +54,17 @@ TARGET_LINK_LIBRARIES(
${CMAKE_THREAD_LIBS_INIT}
)

INSTALL(TARGETS piehid piehid_static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
PUBLIC_HEADER DESTINATION include )

IF(BUILD_STATIC_LIBS)
INSTALL(TARGETS piehid piehid_static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
PUBLIC_HEADER DESTINATION include )
ELSE()
INSTALL(TARGETS piehid
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
PUBLIC_HEADER DESTINATION include )
ENDIF (BUILD_STATIC_LIBS)