[libconfig] init #1343

This commit is contained in:
atkawa7 2017-06-28 13:21:01 -07:00
parent 04e6031027
commit 0e34f81390
4 changed files with 218 additions and 0 deletions

View File

@ -0,0 +1,69 @@
cmake_minimum_required(VERSION 3.5.1)
project(libconfig C CXX)
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
)
set(CPP_SOURCES
${SOURCE_PATH}/libconfigcpp.cc
)
file(COPY ${C_HEADERS} DESTINATION ${COMMON_INCLUDES})
include_directories(${COMMON_INCLUDES})
include_directories(${EXTERNAL_HEADERS})
if(BUILD_SHARED)
add_library(libconfig SHARED ${C_SOURCES})
add_library(libconfig++ SHARED ${C_SOURCES} ${CPP_SOURCES})
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()
install(
TARGETS libconfig libconfig++
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
if(NOT DISABLE_INSTALL_HEADERS)
install(DIRECTORY "${COMMON_INCLUDES}/" DESTINATION include FILES_MATCHING PATTERN "*.h")
endif()

4
ports/libconfig/CONTROL Normal file
View File

@ -0,0 +1,4 @@
Source: libconfig
Version: 1.6.0
Description: Library for collision detection between two convex shapes
Build-Depends: msinttypes, dirent

View File

@ -0,0 +1,34 @@
include(vcpkg_common_functions)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO hyperrealm/libconfig
REF v1.6
SHA512 6222110851970fda11d21e73bc322be95fb1ce62c513e2f4cc7875d7b32d1d211860971692db679edf8ac46151033a132fc669bd16590fec56360ef3a6e584f8
HEAD_REF master
)
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 ${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
)
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libconfig RENAME copyright)

111
ports/libconfig/scandir.c Normal file
View File

@ -0,0 +1,111 @@
// "$Id: scandir.c 1339 2006-04-03 22:47:29Z spitzak $"
//
// Copyright 1998-2006 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "fltk-bugs@fltk.org".
// Emulation of posix scandir() call
// This source file is #include'd by scandir.c
// THIS IS A C FILE! DO NOT CHANGE TO C++!!!
#include <string.h>
#include <windows.h>
#include <stdlib.h>
#include <io.h>
#include <dirent.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef FILENAME_MAX
#define FILENAME_MAX 2048
#endif
/**
* The scandir() function reads the directory dirname and builds an array of
* pointers to directory entries. It returns the number of entries in the array.
* A pointer to the array of directory entries is stored in the location
* referenced by namelist.
*/
int scandir(const char *dirname, struct dirent ***namelist,
int (*select)(struct dirent *),
int (*compar)(struct dirent **, struct dirent **)) {
char *d;
WIN32_FIND_DATA find;
HANDLE h;
int nDir = 0, NDir = 0;
struct dirent **dir = 0, *selectDir;
unsigned long ret;
char findIn[MAX_PATH*4];
//utf8tomb(dirname, strlen(dirname), findIn, _MAX_PATH);
strcpy(findIn, dirname);
d = findIn+strlen(findIn);
if (d==findIn) *d++ = '.';
if (*(d-1)!='/' && *(d-1)!='\\') *d++ = '/';
*d++ = '*';
*d++ = 0;
if ((h=FindFirstFile(findIn, &find))==INVALID_HANDLE_VALUE) {
ret = GetLastError();
if (ret != ERROR_NO_MORE_FILES) {
// TODO: return some error code
}
*namelist = dir;
return nDir;
}
do {
selectDir=(struct dirent*)malloc(sizeof(struct dirent));
strcpy(selectDir->d_name, find.cFileName);
if (!select || (*select)(selectDir)) {
if (nDir==NDir) {
struct dirent **tempDir = (struct dirent **)calloc(sizeof(struct dirent*), NDir+33);
if (NDir) memcpy(tempDir, dir, sizeof(struct dirent*)*NDir);
if (dir) free(dir);
dir = tempDir;
NDir += 32;
}
dir[nDir] = selectDir;
nDir++;
dir[nDir] = 0;
} else {
free(selectDir);
}
} while (FindNextFile(h, &find));
ret = GetLastError();
if (ret != ERROR_NO_MORE_FILES) {
// TODO: return some error code
}
FindClose(h);
if (compar) qsort (dir, nDir, sizeof(*dir),
(int(*)(const void*, const void*))compar);
*namelist = dir;
return nDir;
}
#ifdef __cplusplus
}
#endif
//
// End of "$Id: scandir.c 1339 2006-04-03 22:47:29Z spitzak $".
//