adapt xx.cmake to msvc

This commit is contained in:
taipingchangan 2022-08-26 10:48:53 +08:00
parent d6e6872183
commit 2001a98c09
16 changed files with 252 additions and 44 deletions

View File

@ -117,6 +117,8 @@ endif()
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()
include(${CMAKE_SOURCE_DIR}/cmake/init.cmake)
add_subdirectory(mindspore/ccsrc)
add_subdirectory(mindspore/core)

View File

@ -15,6 +15,9 @@
@echo off
@title mindspore_build
@echo off
echo Start build at: %date% %time%
SET BASE_PATH=%CD%
SET BUILD_PATH=%BASE_PATH%/build
@ -55,8 +58,21 @@ IF "%1%" == "lite" (
-DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - MinGW Makefiles" "%BASE_PATH%/mindspore/lite"
)
) ELSE (
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^
-G "CodeBlocks - MinGW Makefiles" ../..
IF "%1%" == "ms_vs_gpu" (
echo "======Start gen VS2019 Project for MS gpu ======"
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_GPU=ON -DMS_REQUIRE_CUDA_VERSION=11.1 -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^
-G "Visual Studio 16 2019" -A x64 ../..
) ELSE (
IF "%1%" == "ms_vs_cpu" (
echo "======Start gen VS2019 Project for MS cpu ======"
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^
-G "Visual Studio 16 2019" -A x64 ../..
) ELSE (
echo "======Start gen MinGW64 Project for MS cpu ======"
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^
-G "CodeBlocks - MinGW Makefiles" ../..
)
)
)
IF NOT %errorlevel% == 0 (
echo "cmake fail."
@ -64,7 +80,16 @@ IF NOT %errorlevel% == 0 (
EXIT /b 1
)
cmake --build . --target package -- -j%threads%
IF "%1%" == "ms_vs_gpu" (
cmake --build . --config Release --target package
) ELSE (
IF "%1%" == "ms_vs_cpu" (
cmake --build . --config Release --target package
) ELSE (
cmake --build . --target package -- -j%threads%
)
)
IF NOT %errorlevel% == 0 (
echo "build fail."
call :clean
@ -81,4 +106,7 @@ EXIT /b 0
rd /s /q _CPack_Packages
)
)
cd %BASE_PATH%
cd %BASE_PATH%
@echo off
echo End build at: %date% %time%

View File

@ -1,7 +1,10 @@
if(MSVC)
set(flatbuffers_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_CXXFLAGS "/DWIN32 /D_WINDOWS /W3 /GR /EHsc")
set(flatbuffers_CFLAGS "${CMAKE_C_FLAGS}")
set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
# flatbuffers.lib cimplied by msvc
set(CMAKE_STATIC_LIBRARY_PREFIX "")
else()
set(flatbuffers_CXXFLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong")
set(flatbuffers_CFLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -fstack-protector-strong")
@ -61,6 +64,12 @@ endif()
include_directories(${flatbuffers_INC})
add_library(mindspore::flatbuffers ALIAS flatbuffers::flatbuffers)
add_executable(mindspore::flatc ALIAS flatbuffers::flatc)
# recover original value
if(MSVC)
set(CMAKE_STATIC_LIBRARY_PREFIX, ${_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX})
endif()
function(ms_build_flatbuffers source_schema_files
source_schema_dirs
custom_target_name

View File

@ -11,7 +11,12 @@ if(BUILD_LITE)
set(glog_patch ${TOP_DIR}/third_party/patch/glog/glog.patch001)
set(glog_lib mindspore_glog)
else()
set(glog_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_CXX_FLAGS} -Dgoogle=mindspore_private")
if(MSVC)
# add "/EHsc", for vs2019 warning C4530 about glog
set(glog_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_CXX_FLAGS} -Dgoogle=mindspore_private /EHsc")
else()
set(glog_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_CXX_FLAGS} -Dgoogle=mindspore_private")
endif()
set(glog_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(glog_patch ${CMAKE_SOURCE_DIR}/third_party/patch/glog/glog.patch001)
set(glog_lib mindspore_glog)

View File

@ -11,8 +11,12 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(jpeg_turbo_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -D_FORTIFY_SOURCE=2 \
-O2")
else()
set(jpeg_turbo_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC \
-D_FORTIFY_SOURCE=2 -O2")
if(MSVC)
set(jpeg_turbo_CFLAGS "-O2")
else()
set(jpeg_turbo_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC \
-D_FORTIFY_SOURCE=2 -O2")
endif()
endif()
set(jpeg_turbo_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack,-s")

View File

@ -1,5 +1,5 @@
if(MSVC)
set(opencv_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(opencv_CXXFLAGS "/DWIN32 /D_WINDOWS /W3 /GR /EHsc /std:c++17")
set(opencv_CFLAGS "${CMAKE_C_FLAGS}")
set(opencv_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

View File

@ -19,8 +19,16 @@ else()
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC \
-fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
-fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
if(MSVC)
set(protobuf_CXXFLAGS "/DWIN32 /D_WINDOWS /W3 /GR /EHsc")
set(protobuf_CFLAGS "${CMAKE_C_FLAGS}")
set(protobuf_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
else()
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
-fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
endif()
else()
set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \
-fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2")
@ -50,6 +58,18 @@ else()
set(PROTOBUF_PATCH_ROOT ${CMAKE_SOURCE_DIR}/third_party/patch/protobuf)
endif()
if(MSVC)
mindspore_add_pkg(protobuf
VER 3.13.0
LIBS protobuf
EXE protoc
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_PATH cmake/
CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release
-Dprotobuf_MSVC_STATIC_RUNTIME=OFF
PATCHES ${PROTOBUF_PATCH_ROOT}/CVE-2021-22570.patch)
else()
mindspore_add_pkg(protobuf
VER 3.13.0
LIBS protobuf
@ -59,11 +79,13 @@ mindspore_add_pkg(protobuf
CMAKE_PATH cmake/
CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release
PATCHES ${PROTOBUF_PATCH_ROOT}/CVE-2021-22570.patch)
endif()
include_directories(${protobuf_INC})
include_directories(${CMAKE_BINARY_DIR}/proto_py)
add_library(mindspore::protobuf ALIAS protobuf::protobuf)
set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS})
# recover original value
if(MSVC)
set(CMAKE_STATIC_LIBRARY_PREFIX, ${_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX})
endif()

View File

@ -17,16 +17,32 @@ endif()
if(WIN32)
set(sentencepiece_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result -Wno-stringop-overflow \
-Wno-format-extra-args -Wno-format")
if(MSVC)
set(sentencepiece_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 /EHsc")
else()
set(sentencepiece_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result -Wno-stringop-overflow \
-Wno-format-extra-args -Wno-format")
endif()
set(sentencepiece_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(sentencepiece
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_USE_BUILTIN_PROTOBUF=ON -DSPM_ENABLE_SHARED=OFF
MD5 ${MD5}
)
if(MSVC)
mindspore_add_pkg(sentencepiece
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_USE_BUILTIN_PROTOBUF=ON -DSPM_ENABLE_SHARED=OFF
MD5 ${MD5}
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/sentencepiece/sentencepiece_msvc.patch001
)
else()
mindspore_add_pkg(sentencepiece
VER 0.1.92
LIBS sentencepiece sentencepiece_train
URL ${REQ_URL}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DSPM_USE_BUILTIN_PROTOBUF=ON -DSPM_ENABLE_SHARED=OFF
MD5 ${MD5}
)
endif()
else()
set(sentencepiece_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result -Wno-sign-compare")
set(sentencepiece_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")

View File

@ -8,15 +8,25 @@ endif()
if(WIN32)
mindspore_add_pkg(sqlite
VER 3.36.0
LIBS sqlite3
URL https://sqlite.org/2021/sqlite-amalgamation-3360000.zip
MD5 c5d360c74111bafae1b704721ff18fe6
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/sqlite/sqlite.windows.patch002
CMAKE_OPTION " "
)
if(MSVC)
mindspore_add_pkg(sqlite
VER 3.36.0
LIBS sqlite3
URL https://sqlite.org/2021/sqlite-amalgamation-3360000.zip
MD5 c5d360c74111bafae1b704721ff18fe6
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/sqlite/sqlite.windows.msvc.patch001
CMAKE_OPTION " "
)
else()
mindspore_add_pkg(sqlite
VER 3.36.0
LIBS sqlite3
URL https://sqlite.org/2021/sqlite-amalgamation-3360000.zip
MD5 c5d360c74111bafae1b704721ff18fe6
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/sqlite/sqlite.windows.patch002
CMAKE_OPTION " "
)
endif()
else()
set(sqlite_USE_STATIC_LIBS ON)
set(sqlite_CXXFLAGS)

View File

@ -1,5 +1,10 @@
set(tinyxml2_CXXFLAGS "-fstack-protector -D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result")
set(tinyxml2_CFLAGS "-fstack-protector -D_FORTIFY_SOURCE=2 -O2")
if(MSVC)
set(tinyxml2_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(tinyxml2_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
else()
set(tinyxml2_CXXFLAGS "-fstack-protector -D_FORTIFY_SOURCE=2 -O2 -Wno-unused-result")
set(tinyxml2_CFLAGS "-fstack-protector -D_FORTIFY_SOURCE=2 -O2")
endif()
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/tinyxml2/repository/archive/8.0.0.tar.gz")

42
cmake/init.cmake Normal file
View File

@ -0,0 +1,42 @@
# Attention: cmake will append these flags to compile command automatically.
# So if you want to add global option, change this file rather than flags.cmake
# Linux
# DEBUG: default: "-g"
# RELEASE: default: "-O3 -DNDEBUG"
# RELWITHDEBINFO: default: "-O2 -g -DNDEBUG"
# MINSIZEREL: default: "-O2 -g -DNDEBUG"
if(MSVC)
message("init cxx_flags on windows")
cmake_host_system_information(RESULT CPU_CORES QUERY NUMBER_OF_LOGICAL_CORES)
message("CPU_CORE number = ${CPU_CORES}")
math(EXPR MP_NUM "${CPU_CORES} * 2")
set(CMAKE_C_FLAGS "/MD /O2 /Ob2 /DNDEBUG /MP${MP_NUM} /EHsc")
set(CMAKE_C_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1 /MP${MP_NUM} /EHsc")
set(CMAKE_C_FLAGS_RELEASE "/MD /O2 /Ob2 /DNDEBUG /MP${MP_NUM} /EHsc")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/MD /Zi /O2 /Ob1 /DNDEBUG /MP${MP_NUM} /EHsc")
set(CMAKE_C_FLAGS_MINSIZEREL "/MD /O1 /Ob1 /DNDEBUG /MP${MP_NUM} /EHsc")
set(CMAKE_CXX_FLAGS "/MD /O2 /Ob2 /DNDEBUG /MP${MP_NUM} /EHsc")
set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1 /MP${MP_NUM} /EHsc")
set(CMAKE_CXX_FLAGS_RELEASE "/MD /O2 /Ob2 /DNDEBUG /MP${MP_NUM} /EHsc")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /O2 /Ob1 /DNDEBUG /MP${MP_NUM} /EHsc")
set(CMAKE_CXX_FLAGS_MINSIZEREL "/MD /O1 /Ob1 /DNDEBUG /MP${MP_NUM} /EHsc")
# resolve std::min/std::max and opencv::min opencv:max had defined in windows.h
add_definitions(-DNOMINMAX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4251 /wd4819 /wd4715 /wd4244 /wd4267 /wd4716")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251 /wd4819 /wd4715 /wd4244 /wd4267 /wd4716")
if(ENABLE_GPU)
message("init cxx_flags on windows_gpu")
set(CMAKE_CUDA_FLAGS "-Xcompiler=\"-MD /MP${MP_NUM} -O2 -Ob2\" -DNDEBUG")
set(CMAKE_CUDA_FLAGS_DEBUG "-Xcompiler=\"-MDd /MP${MP_NUM} -Zi -Ob0 -Od /RTC1\"")
set(CMAKE_CUDA_FLAGS_RELEASE "-Xcompiler=\"-MD /MP${MP_NUM} -O2 -Ob2\" -DNDEBUG")
set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "-Xcompiler=\"-MD /MP${MP_NUM} -Zi -O2 -Ob1\" -DNDEBUG")
set(CMAKE_CUDA_FLAGS_MINSIZEREL "-Xcompiler=\"-MD /MP${MP_NUM} -O1 -Ob1\" -DNDEBUG")
endif()
endif()

View File

@ -7,7 +7,11 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
endif()
endif()
set(_ms_tmp_CMAKE_CXX_FLAGS_F ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()
set(TOP_DIR ${CMAKE_SOURCE_DIR})
include(cmake/utils.cmake)

View File

@ -83,7 +83,11 @@ install(
)
if(USE_GLOG)
file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libmindspore_glog.dll)
if(MSVC)
file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/mindspore_glog.dll)
else()
file(GLOB_RECURSE GLOG_LIB_LIST ${glog_LIBPATH}/libmindspore_glog.dll)
endif()
install(
FILES ${GLOG_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
@ -98,18 +102,31 @@ if(ENABLE_MINDDATA)
DESTINATION ${INSTALL_BASE_DIR}
COMPONENT mindspore
)
file(GLOB_RECURSE OPENCV_LIB_LIST
${opencv_LIBPATH}/libopencv_core*
${opencv_LIBPATH}/libopencv_imgcodecs*
${opencv_LIBPATH}/libopencv_imgproc*
)
if(MSVC)
file(GLOB_RECURSE OPENCV_LIB_LIST
${opencv_LIBPATH}/opencv_core*
${opencv_LIBPATH}/opencv_imgcodecs*
${opencv_LIBPATH}/opencv_imgproc*
)
else()
file(GLOB_RECURSE OPENCV_LIB_LIST
${opencv_LIBPATH}/libopencv_core*
${opencv_LIBPATH}/libopencv_imgcodecs*
${opencv_LIBPATH}/libopencv_imgproc*
)
endif()
install(
FILES ${OPENCV_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
file(GLOB_RECURSE TINYXML2_LIB_LIST ${tinyxml2_LIBPATH}/libtinyxml2.dll)
if(MSVC)
file(GLOB_RECURSE TINYXML2_LIB_LIST ${tinyxml2_LIBPATH}/tinyxml2.dll)
else()
file(GLOB_RECURSE TINYXML2_LIB_LIST ${tinyxml2_LIBPATH}/libtinyxml2.dll)
endif()
install(
FILES ${TINYXML2_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
@ -167,7 +184,7 @@ if(ENABLE_GPU)
)
endif()
install(
TARGETS gpu_queue
TARGETS cuda_ops
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
@ -180,13 +197,22 @@ string(REPLACE "\\" "/" SystemRoot $ENV{SystemRoot})
file(GLOB VC_LIB_LIST ${SystemRoot}/System32/msvcp140.dll ${SystemRoot}/System32/vcomp140.dll)
file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
install(
FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} ${VC_LIB_LIST}
FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${VC_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
if(NOT MSVC)
file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
install(
FILES ${SQLITE_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif()
# set python files
file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/python/mindspore/*.py)
install(

View File

@ -142,6 +142,7 @@ function(__find_pkg_then_add_target pkg_name pkg_exe lib_path)
NO_DEFAULT_PATH)
endif()
if(NOT ${_LIB_NAME}_LIB)
message("not find ${_LIB_SEARCH_NAME} in path: ${${pkg_name}_BASE_DIR}/${lib_path}")
return()
endif()
@ -375,8 +376,13 @@ function(mindspore_add_pkg pkg_name)
${${pkg_name}_CMAKE_CFLAGS} ${${pkg_name}_CMAKE_CXXFLAGS} ${${pkg_name}_CMAKE_LDFLAGS}
-DCMAKE_INSTALL_PREFIX=${${pkg_name}_BASE_DIR} ${${pkg_name}_SOURCE_DIR}/${PKG_CMAKE_PATH}
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build)
__exec_cmd(COMMAND ${CMAKE_COMMAND} --build . --target install -- -j${THNUM}
if(MSVC)
__exec_cmd(COMMAND ${CMAKE_COMMAND} --build . --config Release --target install --
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build)
else()
__exec_cmd(COMMAND ${CMAKE_COMMAND} --build . --target install -- -j${THNUM}
WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build)
endif()
endif()
else()
if(${pkg_name}_CFLAGS)

View File

@ -0,0 +1,19 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6481dfd..3291791 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,10 +43,10 @@ else()
endif()
if (MSVC)
- string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
- string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL})
- string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
- string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
+ string(REPLACE "/MT" "/MD" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
+ string(REPLACE "/MT" "/MD" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL})
+ string(REPLACE "/MT" "/MD" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
+ string(REPLACE "/MT" "/MD" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
add_definitions("/wd4267 /wd4244 /wd4305 /Zc:strictStrings /utf-8")
endif()

View File

@ -0,0 +1,10 @@
diff -Npur sqlite-amalgamation-3360000/CMakeLists.txt sqlite-amalgamation-3360000-patch/CMakeLists.txt
--- sqlite-amalgamation-3360000/CMakeLists.txt 1970-01-01 08:00:00.000000000 +0800
+++ sqlite-amalgamation-3360000-patch/CMakeLists.txt 2021-12-17 16:08:55.519134222 +0800
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.14)
+project (SqliteC)
+add_library(sqlite3 STATIC sqlite3.c)
+set_target_properties(sqlite3 PROPERTIES PUBLIC_HEADER "sqlite3.h;sqlite3ext.h")
+include(GNUInstallDirs)
+install(TARGETS sqlite3 PUBLIC_HEADER)