Skip to content

Commit

Permalink
Build only a single library type, static or shared
Browse files Browse the repository at this point in the history
Typically, a static library should be more useful for UCDN. Use the
standard BUILD_SHARED_LIBS toggle of CMake to switch between the
library types, and link a static library by default.

If both library types are desired, they have to be built and installed
separately, but this should be a non-issue.
  • Loading branch information
grigorig committed Oct 1, 2012
1 parent ec286fe commit b7fb496
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
cmake_minimum_required(VERSION 2.6)
project(ucdn C)

ADD_DEFINITIONS(-O2 -Wall -Werror -pedantic -std=c89)
add_definitions(-O2 -Wall -Werror -pedantic -std=c89)

add_library(ucdn_static STATIC ucdn.c ucdn.h)
add_library(ucdn_shared SHARED ucdn.c ucdn.h)
set_target_properties(ucdn_static PROPERTIES OUTPUT_NAME ucdn)
set_target_properties(ucdn_shared PROPERTIES OUTPUT_NAME ucdn)
set_target_properties(ucdn_shared PROPERTIES VERSION 1.0.0)
set_target_properties(ucdn_shared PROPERTIES SOVERSION 1)
add_library(ucdn ucdn.c ucdn.h)

if(BUILD_SHARED_LIBS)
set_target_properties(ucdn PROPERTIES VERSION 1.0.0)
set_target_properties(ucdn PROPERTIES SOVERSION 1)
endif()

add_executable(ucdn-test ucdn-test.c)
target_link_libraries(ucdn-test ucdn_static)
target_link_libraries(ucdn-test ucdn)

install(TARGETS ucdn_static ucdn_shared
install(TARGETS ucdn
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(FILES ucdn.h DESTINATION include)

0 comments on commit b7fb496

Please sign in to comment.