[cgicc]Fix usage error:lnk2019. (#8558)

* [cgicc]Fix usage error:lnk2019.

* [cgicc]Fix static build.

* [cgicc]Modify precompiled macro judgments based on library linkage.
This commit is contained in:
Jack·Boos·Yu 2020-01-11 07:51:51 +08:00 committed by dan-shaw
parent fc34b74ce2
commit bc01338fe2
3 changed files with 33 additions and 1 deletions

View File

@ -104,6 +104,12 @@ set (cgicc_HEADERS
include_directories (. ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
add_library (cgicc ${cgicc_SOURCES} ${cgicc_HEADERS})
if (BUILD_SHARED_LIBS)
add_definitions(-DCGICC_EXPORTS)
else()
add_definitions(-DCGICC_STATIC)
endif()
install(TARGETS cgicc
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib

View File

@ -0,0 +1,15 @@
diff --git a/cgicc/CgiDefs.h.in b/cgicc/CgiDefs.h.in
index 71b70ad..3793cd8 100644
--- a/cgicc/CgiDefs.h.in
+++ b/cgicc/CgiDefs.h.in
@@ -47,7 +47,9 @@
#ifdef WIN32
// export library symbols
-# ifdef CGICC_EXPORTS
+# ifdef CGICC_STATIC
+# define CGICC_API
+# elif defined(CGICC_EXPORTS)
# define CGICC_API __declspec(dllexport)
# else
# define CGICC_API __declspec(dllimport)

View File

@ -11,7 +11,9 @@ vcpkg_download_distfile(ARCHIVE
vcpkg_extract_source_archive_ex(
ARCHIVE ${ARCHIVE}
OUT_SOURCE_PATH SOURCE_PATH
PATCHES fix-define.patch
PATCHES
fix-define.patch
fix-static-build.patch
)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
@ -27,4 +29,13 @@ vcpkg_configure_cmake(
vcpkg_install_cmake()
vcpkg_copy_pdbs()
file(READ ${CURRENT_PACKAGES_DIR}/include/cgicc/CgiDefs.h CGI_H)
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
string(REPLACE "# ifdef CGICC_STATIC" "# if 0" CGI_H "${CGI_H}")
else()
string(REPLACE "# ifdef CGICC_STATIC" "# if 1" CGI_H "${CGI_H}")
endif()
file(WRITE ${CURRENT_PACKAGES_DIR}/include/cgicc/CgiDefs.h "${CGI_H}")
file(INSTALL ${SOURCE_PATH}/COPYING.DOC DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)