[libconfig] fixed issues with portfile

This commit is contained in:
atkawa7 2017-06-29 13:38:45 -07:00
parent aa56370103
commit f114e81a75
2 changed files with 16 additions and 48 deletions

View File

@ -6,53 +6,29 @@ if(MSVC)
add_compile_options(/W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS)
endif()
set(SOURCE_PATH ${PROJECT_SOURCE_DIR}/lib)
set(COMMON_INCLUDES ${PROJECT_BINARY_DIR}/includes)
set(C_HEADERS
${SOURCE_PATH}/grammar.h
${SOURCE_PATH}/libconfig.h
${SOURCE_PATH}/libconfig.hh
${SOURCE_PATH}/parsectx.h
${SOURCE_PATH}/scanctx.h
${SOURCE_PATH}/scanner.h
${SOURCE_PATH}/wincompat.h
${SOURCE_PATH}/libconfig.h++
${SOURCE_PATH}/libconfigcpp.c++
)
set(
EXTERNAL_HEADERS ${SOURCE_PATH}/win32
)
set(C_SOURCES
${SOURCE_PATH}/grammar.c
${SOURCE_PATH}/libconfig.c
${SOURCE_PATH}/scanctx.c
${SOURCE_PATH}/win32/scandir.c
${SOURCE_PATH}/scanner.c
${SOURCE_PATH}/strbuf.c
lib/grammar.c
lib/libconfig.c
lib/scanctx.c
lib/win32/scandir.c
lib/scanner.c
lib/strbuf.c
)
set(CPP_SOURCES
${SOURCE_PATH}/libconfigcpp.cc
lib/libconfigcpp.cc
)
file(COPY ${C_HEADERS} DESTINATION ${COMMON_INCLUDES})
include_directories(lib)
include_directories(lib/win32)
include_directories(${COMMON_INCLUDES})
include_directories(${EXTERNAL_HEADERS})
add_library(libconfig ${C_SOURCES})
add_library(libconfig++ ${C_SOURCES} ${CPP_SOURCES})
if(BUILD_SHARED)
add_library(libconfig SHARED ${C_SOURCES})
add_library(libconfig++ SHARED ${C_SOURCES} ${CPP_SOURCES})
if(BUILD_SHARED_LIBS)
target_compile_definitions(libconfig PRIVATE -DLIBCONFIG_EXPORTS -DYY_NO_UNISTD_H -DYY_USE_CONST)
target_compile_definitions(libconfig++ PRIVATE -DLIBCONFIG_EXPORTS -DLIBCONFIGXX_EXPORTS -DYY_NO_UNISTD_H -DYY_USE_CONST)
else()
add_library(libconfig STATIC ${C_SOURCES})
add_library(libconfig++ STATIC ${C_SOURCES} ${CPP_SOURCES})
target_compile_definitions(libconfig PRIVATE -DLIBCONFIG_STATIC -DYY_NO_UNISTD_H)
target_compile_definitions(libconfig++ PRIVATE -DLIBCONFIG_STATIC -DYY_NO_UNISTD_H)
endif()
@ -65,5 +41,5 @@ install(
)
if(NOT DISABLE_INSTALL_HEADERS)
install(DIRECTORY "${COMMON_INCLUDES}/" DESTINATION include)
install(FILES lib/libconfig.h++ lib/libconfig.h DESTINATION include)
endif()

View File

@ -15,27 +15,19 @@ vcpkg_apply_patches(
"${CMAKE_CURRENT_LIST_DIR}/fix-scanner-header-msvc-patch.patch"
)
set(DIRENT_HOME ${VCPKG_ROOT_DIR}/packages/dirent_${TARGET_TRIPLET})
set(MIINTTYPES_HOME ${VCPKG_ROOT_DIR}/packages/msinttypes_${TARGET_TRIPLET})
set(WIN_SRC ${SOURCE_PATH}/lib/win32)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/scandir.c DESTINATION ${WIN_SRC})
file(COPY ${CURRENT_INSTALLED_DIR}/include/dirent.h DESTINATION ${WIN_SRC})
file(COPY ${CURRENT_INSTALLED_DIR}/include/stdint.h DESTINATION ${WIN_SRC})
file(COPY ${DIRENT_HOME}/include/dirent.h DESTINATION ${WIN_SRC})
file(COPY ${MIINTTYPES_HOME}/include/stdint.h DESTINATION ${WIN_SRC})
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
set (BUILD_SHARED_LIBRARY ON)
else()
set(BUILD_SHARED_LIBRARY OFF)
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS -DBUILD_SHARED=${BUILD_SHARED_LIBRARY}
OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
)
vcpkg_install_cmake()
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libconfig RENAME copyright)