Skip to content

Commit eea2b29

Browse files
committed
Install pkg-config file
1 parent 3660efa commit eea2b29

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ ELSE(MSVC)
4343
SET(WERROR_FLAG "-Werror")
4444
ENDIF(MSVC)
4545

46+
LIST(REMOVE_DUPLICATES SDL2_ALL_INCLUDE_DIRS)
47+
4648
INCLUDE_DIRECTORIES(BEFORE ${PROJECT_SOURCE_DIR})
4749
INCLUDE_DIRECTORIES(${SDL2_ALL_INCLUDE_DIRS})
4850

@@ -107,8 +109,27 @@ IF(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
107109
ADD_SUBDIRECTORY(demos)
108110
ADD_SUBDIRECTORY(tests)
109111

112+
# pkgconfig
113+
SET(PKGCONFIGDIR lib/pkgconfig CACHE STRING "directory where to install pkg-config files")
114+
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
115+
SET(PKGCONFIGDIR libdata/pkgconfig)
116+
ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
117+
118+
SET(SDL2_PKGCONFIG_CFLAGS "")
119+
FOREACH(INCDIR IN LISTS SDL2_ALL_INCLUDE_DIRS)
120+
SET(SDL2_PKGCONFIG_CFLAGS "${SDL2_PKGCONFIG_CFLAGS} -I${INCDIR}")
121+
ENDFOREACH(INCDIR IN SDL2_ALL_INCLUDE_DIRS)
122+
123+
CONFIGURE_FILE(
124+
sdl2pp.pc.in
125+
sdl2pp.pc
126+
@ONLY
127+
)
128+
129+
# install
110130
INSTALL(FILES ${LIBRARY_HEADERS} ${PROJECT_BINARY_DIR}/SDL2pp/Config.hh DESTINATION include/SDL2pp)
111131
INSTALL(TARGETS SDL2pp LIBRARY DESTINATION lib)
132+
INSTALL(FILES ${PROJECT_BINARY_DIR}/sdl2pp.pc DESTINATION ${PKGCONFIGDIR})
112133
ELSE(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
113134
MESSAGE(STATUS "libSDL2pp bundled build")
114135

sdl2pp.pc.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# libSDL2pp pkg-config source file
2+
3+
prefix=@CMAKE_INSTALL_PREFIX@
4+
exec_prefix=${prefix}
5+
libdir=${exec_prefix}/lib
6+
includedir=${prefix}/include
7+
8+
Name: sdl2pp
9+
Description: C++11 bindings/wrappers for SDL2.
10+
Version: @SDL2PP_VERSION@
11+
Requires:
12+
Conflicts:
13+
Libs: -L${libdir} -lSDL2pp
14+
Cflags: -I${includedir}@SDL2_PKGCONFIG_CFLAGS@

0 commit comments

Comments
 (0)