"Fossies" - the Fresh Open Source Software Archive

Member "libmaxminddb-1.5.2/CMakeLists.txt" (18 Feb 2021, 2324 Bytes) of package /linux/misc/libmaxminddb-1.5.2.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "CMakeLists.txt": 1.5.0_vs_1.5.2.

    1 cmake_minimum_required (VERSION 3.9)
    2 project(maxminddb
    3   LANGUAGES C
    4   VERSION 1.5.2
    5 )
    6 set(MAXMINDDB_SOVERSION 0.0.7)
    7 
    8 option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF)
    9 option(BUILD_TESTING "Build test programs" ON)
   10 
   11 include(CheckTypeSize)
   12 check_type_size("unsigned __int128" UINT128)
   13 check_type_size("unsigned int __attribute__((mode(TI)))" UINT128_USING_MODE)
   14 if(HAVE_UINT128)
   15   set(MMDB_UINT128_USING_MODE 0)
   16   set(MMDB_UINT128_IS_BYTE_ARRAY 0)
   17 elseif(HAVE_UINT128_USING_MODE)
   18   set(MMDB_UINT128_USING_MODE 1)
   19   set(MMDB_UINT128_IS_BYTE_ARRAY 0)
   20 else()
   21   set(MMDB_UINT128_USING_MODE 0)
   22   set(MMDB_UINT128_IS_BYTE_ARRAY 1)
   23 endif()
   24 
   25 include (TestBigEndian)
   26 TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
   27 
   28 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
   29   set(CMAKE_POSITION_INDEPENDENT_CODE ON)
   30 endif()
   31 
   32 configure_file(${PROJECT_SOURCE_DIR}/include/maxminddb_config.h.cmake.in 
   33                ${PROJECT_SOURCE_DIR}/include/maxminddb_config.h)
   34 
   35 add_library(maxminddb
   36   src/maxminddb.c
   37   src/data-pool.c
   38 )
   39 add_library(maxminddb::maxminddb ALIAS maxminddb)
   40 
   41 set_target_properties(maxminddb PROPERTIES VERSION ${MAXMINDDB_SOVERSION})
   42 
   43 target_compile_definitions(maxminddb PUBLIC PACKAGE_VERSION="${PROJECT_VERSION}")
   44 
   45 if(NOT IS_BIG_ENDIAN)
   46   target_compile_definitions(maxminddb PRIVATE MMDB_LITTLE_ENDIAN=1)
   47 endif()
   48 
   49 if(MSVC)
   50   target_compile_definitions(maxminddb PRIVATE _CRT_SECURE_NO_WARNINGS)
   51 endif()
   52 
   53 if(WIN32)
   54   target_link_libraries(maxminddb ws2_32)
   55 endif()
   56 
   57 set(CMAKE_SHARED_LIBRARY_PREFIX lib)
   58 set(CMAKE_STATIC_LIBRARY_PREFIX lib)
   59 
   60 set(MAXMINDB_INCLUDE_DIR
   61   .
   62   include
   63 )
   64 
   65 target_include_directories(maxminddb PUBLIC
   66   $<BUILD_INTERFACE:${MAXMINDB_INCLUDE_DIR}>
   67   $<INSTALL_INTERFACE:include>
   68 )
   69 
   70 set(MAXMINDB_HEADERS
   71   include/maxminddb.h
   72   include/maxminddb_config.h
   73 )
   74 set_target_properties(maxminddb PROPERTIES PUBLIC_HEADER "${MAXMINDB_HEADERS}")
   75 
   76 install(TARGETS maxminddb
   77         EXPORT maxminddb
   78         ARCHIVE DESTINATION lib
   79         PUBLIC_HEADER DESTINATION include/
   80 )
   81 
   82 # This is required to work with FetchContent
   83 install(EXPORT maxminddb
   84         FILE maxminddb-config.cmake
   85         NAMESPACE maxminddb::
   86         DESTINATION lib/cmake/maxminddb)
   87 
   88 # We always want to build mmdblookup
   89 add_subdirectory(bin)
   90 
   91 if (BUILD_TESTING)
   92   enable_testing()
   93   add_subdirectory(t)
   94 endif()
   95