Commit 0846daab authored by Davis E. King's avatar Davis E. King

Merge pull request #108 from SoapGentoo/master

Augment build-system, allow for multilib installation, support pkg-config discovery
parents cad73fae f3eae438
...@@ -79,6 +79,7 @@ if (NOT TARGET dlib) ...@@ -79,6 +79,7 @@ if (NOT TARGET dlib)
set (DLIB_LINK_WITH_SQLITE3_STR set (DLIB_LINK_WITH_SQLITE3_STR
"Disable this if you don't want to link against sqlite3" ) "Disable this if you don't want to link against sqlite3" )
#set (DLIB_USE_FFTW_STR "Disable this if you don't want to link against fftw" ) #set (DLIB_USE_FFTW_STR "Disable this if you don't want to link against fftw" )
set (LIB_INSTALL_DIR lib CACHE STRING "Install location of libraries (e.g. lib32 or lib64 for multilib installations)")
option(DLIB_ISO_CPP_ONLY ${DLIB_ISO_CPP_ONLY_STR} OFF) option(DLIB_ISO_CPP_ONLY ${DLIB_ISO_CPP_ONLY_STR} OFF)
toggle_preprocessor_switch(DLIB_ISO_CPP_ONLY) toggle_preprocessor_switch(DLIB_ISO_CPP_ONLY)
...@@ -308,6 +309,7 @@ if (NOT TARGET dlib) ...@@ -308,6 +309,7 @@ if (NOT TARGET dlib)
if (PNG_FOUND AND LIBPNG_IS_GOOD) if (PNG_FOUND AND LIBPNG_IS_GOOD)
include_directories(${PNG_INCLUDE_DIR}) include_directories(${PNG_INCLUDE_DIR})
set (dlib_needed_libraries ${dlib_needed_libraries} ${PNG_LIBRARY}) set (dlib_needed_libraries ${dlib_needed_libraries} ${PNG_LIBRARY})
set(REQUIRES_LIBS " libpng")
else() else()
# If we can't find libpng then statically compile it in. # If we can't find libpng then statically compile it in.
include_directories(external/libpng external/zlib) include_directories(external/libpng external/zlib)
...@@ -343,6 +345,7 @@ if (NOT TARGET dlib) ...@@ -343,6 +345,7 @@ if (NOT TARGET dlib)
external/zlib/uncompr.c external/zlib/uncompr.c
external/zlib/zutil.c external/zlib/zutil.c
) )
set(REQUIRES_LIBS "")
endif() endif()
set(source_files ${source_files} set(source_files ${source_files}
image_loader/png_loader.cpp image_loader/png_loader.cpp
...@@ -575,8 +578,8 @@ if (NOT TARGET dlib) ...@@ -575,8 +578,8 @@ if (NOT TARGET dlib)
install(TARGETS dlib dlib_shared install(TARGETS dlib dlib_shared
EXPORT dlib EXPORT dlib
RUNTIME DESTINATION bin # Windows (including cygwin) considers .dll to be runtime artifacts RUNTIME DESTINATION bin # Windows (including cygwin) considers .dll to be runtime artifacts
LIBRARY DESTINATION lib LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
ARCHIVE DESTINATION lib) ARCHIVE DESTINATION "${LIB_INSTALL_DIR}")
else() else()
install(TARGETS dlib install(TARGETS dlib
EXPORT dlib EXPORT dlib
...@@ -601,7 +604,7 @@ if (NOT TARGET dlib) ...@@ -601,7 +604,7 @@ if (NOT TARGET dlib)
## Config.cmake generation and installation ## Config.cmake generation and installation
set(ConfigPackageLocation lib/cmake/dlib) set(ConfigPackageLocation "${LIB_INSTALL_DIR}/cmake/dlib")
install(EXPORT dlib install(EXPORT dlib
NAMESPACE dlib:: NAMESPACE dlib::
DESTINATION ${ConfigPackageLocation}) DESTINATION ${ConfigPackageLocation})
...@@ -620,6 +623,13 @@ if (NOT TARGET dlib) ...@@ -620,6 +623,13 @@ if (NOT TARGET dlib)
"${CMAKE_CURRENT_BINARY_DIR}/config/dlibConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config/dlibConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/config/dlibConfigVersion.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config/dlibConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}) DESTINATION ${ConfigPackageLocation})
## dlib-1.pc generation and installation
configure_file("dlib.pc.in" "dlib-1.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dlib-1.pc"
DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
endif() endif()
endif() endif()
...@@ -40,6 +40,20 @@ if (UNIX) ...@@ -40,6 +40,20 @@ if (UNIX)
return() return()
endif() endif()
# First, search for libraries via pkg-config, which is the cleanest path
find_package(PkgConfig)
pkg_check_modules(BLAS_REFERENCE cblas)
pkg_check_modules(LAPACK_REFERENCE lapack)
if (BLAS_REFERENCE_FOUND AND LAPACK_REFERENCE_FOUND)
set(blas_libraries "${BLAS_REFERENCE_LDFLAGS}")
set(lapack_libraries "${LAPACK_REFERENCE_LDFLAGS}")
set(blas_found 1)
set(lapack_found 1)
set(REQUIRES_LIBS "${REQUIRES_LIBS} cblas lapack")
message(STATUS "Found BLAS and LAPACK via pkg-config")
return()
endif()
include(CheckTypeSize) include(CheckTypeSize)
check_type_size( "void*" SIZE_OF_VOID_PTR) check_type_size( "void*" SIZE_OF_VOID_PTR)
......
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/@LIB_INSTALL_DIR@
includedir=${prefix}/include
Name: @PROJECT_NAME@
Description: Numerical and networking C++ library
Version: @VERSION@
Libs: -L${libdir} -ldlib
Cflags: -I${includedir}
Requires:@REQUIRES_LIBS@
...@@ -5,14 +5,15 @@ ...@@ -5,14 +5,15 @@
TARGET = dtest TARGET = dtest
# these are the compile time flags passed to gcc # these are the compile time flags passed to gcc
CFLAGS = -ggdb -DDEBUG -DDLIB_NO_GUI_SUPPORT -I ../.. -Wall CXXFLAGS ?= -ggdb -Wall
CPPFLAGS ?= -DDEBUG -DDLIB_NO_GUI_SUPPORT -I../..
# These are the link time flags passed to gcc # These are the link time flags passed to gcc
LFLAGS = -lpthread -lnsl LFLAGS = -lpthread -lnsl
# The name of the compiler. If you only have one version of # The name of the compiler. If you only have one version of
# gcc installed then you probably want to change this to just g++ # gcc installed then you probably want to change this to just g++
CC = nice g++ CXX ?= nice g++
#################################################### ####################################################
#################################################### ####################################################
...@@ -165,13 +166,9 @@ OBJ = $(TMP:.c=.o) ...@@ -165,13 +166,9 @@ OBJ = $(TMP:.c=.o)
$(TARGET): $(OBJ) $(TARGET): $(OBJ)
@echo Linking $@ @echo Linking $@
@$(CC) $(OBJ) $(LFLAGS) -o $@ @$(CXX) $(LDFLAGS) $(OBJ) $(LFLAGS) -o $@
@echo Build Complete @echo Build Complete
.cpp.o: $<
@echo Compiling $<
@$(CC) -c $(CFLAGS) $< -o $@
clean: clean:
@rm -f $(OBJ) $(TARGET) @rm -f $(OBJ) $(TARGET)
@echo All object files and binaries removed @echo All object files and binaries removed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment