Improve CMakeLists and make stuff installable.

This commit is contained in:
Jari Vetoniemi 2014-04-12 22:42:37 +03:00
parent 27b71db67a
commit 3f0f507e4f
2 changed files with 30 additions and 6 deletions

View File

@ -1,7 +1,7 @@
# Sources
SET(CLIENT_SOURCE client.c)
SET(CLIENT_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/../lib")
SET(CLIENT_LIBRARIES bemenu)
SET(CLIENT_INCLUDE ${BEMENU_INCLUDE_DIRS})
SET(CLIENT_LIBRARIES ${BEMENU_LIBRARIES})
# Warnings
IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
@ -20,5 +20,9 @@ ENDIF ()
INCLUDE_DIRECTORIES(${CLIENT_INCLUDE})
ADD_EXECUTABLE(client ${CLIENT_SOURCE})
TARGET_LINK_LIBRARIES(client ${CLIENT_LIBRARIES})
SET_TARGET_PROPERTIES(client PROPERTIES OUTPUT_NAME bemenu)
# Install
INSTALL(TARGETS client DESTINATION bin)
# vim: set ts=8 sw=4 tw=0 :

View File

@ -8,9 +8,8 @@ SET(BEMENU_SOURCE
library.c
draw/curses.c
)
SET(BEMENU_INCLUDE)
SET(BEMENU_LIBRARIES)
# Configure
CONFIGURE_FILE(version.h.in version.h @ONLY)
# Warnings
@ -26,9 +25,30 @@ IF (UNIX AND CMAKE_COMPILER_IS_GNUCC)
ENDIF ()
ENDIF ()
# Parse soversion version
STRING(REGEX MATCHALL "[0-9]+" VERSION_COMPONENTS ${BEMENU_VERSION})
LIST(GET VERSION_COMPONENTS 0 SOVERSION)
# Compile
INCLUDE_DIRECTORIES(${BEMENU_INCLUDE} ${CMAKE_CURRENT_BINARY_DIR})
ADD_LIBRARY(bemenu ${BEMENU_SOURCE})
TARGET_LINK_LIBRARIES(bemenu ${BEMENU_LIBRARIES} dl)
ADD_LIBRARY(bemenu SHARED ${BEMENU_SOURCE})
SET_TARGET_PROPERTIES(bemenu PROPERTIES
VERSION ${BEMENU_VERSION}
SOVERSION ${SOVERSION})
TARGET_LINK_LIBRARIES(bemenu dl)
# Install
INSTALL(TARGETS bemenu DESTINATION lib)
INSTALL(FILES bemenu.h DESTINATION include)
# Unexport
SET(BEMENU_INCLUDES)
SET(BEMENU_INCLUDE_DIRS)
SET(BEMENU_LIBRARIES)
# Export
SET(BEMENU_INCLUDES "bemenu.h" CACHE STRING "bemenu includes exported from CMake")
SET(BEMENU_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "bemenu public header include path exported from CMake")
SET(BEMENU_LIBRARIES "bemenu" "dl" CACHE STRING "bemenu libraries exported from CMake")
# vim: set ts=8 sw=4 tw=0 :