-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Conzxy/win
Win
- Loading branch information
Showing
32 changed files
with
753 additions
and
514 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
if (NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE "Release") | ||
endif() | ||
|
||
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") | ||
|
||
if (CMAKE_BUILD_TYPE STREQUAL "Release") | ||
message(STATUS "CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}") | ||
elseif (CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
message(STATUS "CMAKE_CXX_FLAGS_DEBUG") | ||
elseif (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") | ||
message(STATUS "CMAKE_CXX_FLAGS_MINSIZEREL: ${CMAKE_CXX_FLAGS_MINSIZEREL}") | ||
elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") | ||
message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Check if mmkv is being used directly or via add_subdirectory, but allow overriding | ||
if(NOT DEFINED MMKV_MAIN_PROJECT) | ||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) | ||
set(MMKV_MAIN_PROJECT ON) | ||
else() | ||
set(MMKV_MAIN_PROJECT OFF) | ||
endif() | ||
endif() | ||
|
||
option(MMKV_BUILD_STATIC_LIBS "Build static library of mmkv" ON) | ||
# to install files to proper destination actually. | ||
option(MMKV_INSTALL "Generate the install target" ${MMKV_MAIN_PROJECT}) | ||
|
||
option(MMKV_TESTS "Generate mmkv test targets" OFF) | ||
|
||
# User can determine whether to build all tests when build target all | ||
# e.g. cmake --build */MMKV/build [--target all -j 2] | ||
# If this option is OFF, user should specify target manually. | ||
option(MMKV_BUILD_ALL_TESTS "Build tests when --target all(default) is specified" OFF) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
set(CMAKE_CXX_FLAGS "/DWIN32 /D_WINDOWS /W0 /GR /EHsc /Zc:__cplusplus") | ||
set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1 /Zc:__cplusplus") | ||
set(CMAKE_CXX_FLAGS_RELEASE "/MD /O2 /Ob2 /DNDEBUG /Zc:__cplusplus") | ||
set(CMAKE_CXX_FLAGS_MINSIZEREL "/MD /O1 /Ob1 /DNDEBUG /Zc:__cplusplus") | ||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /O2 /Ob1 /DNDEBUG /Zc:__cplusplus") | ||
else () | ||
# FYI https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html | ||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") | ||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") | ||
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") | ||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Og") | ||
|
||
# FYI https://gcc.gnu.org/onlinedocs/gcc-5.5.0/gcc/Link-Options.html#Link-Options | ||
# FYI https://gcc.gnu.org/onlinedocs/gcc-5.5.0/gcc/Warning-Options.html#Warning-Options | ||
|
||
set(CXX_FLAGS | ||
-Wall | ||
-Wno-attributes | ||
-Wextra | ||
-Wno-return-local-addr | ||
-Wno-unused-parameter | ||
-Wno-unused-function | ||
-Wno-switch | ||
-Wno-format-security | ||
# support INT2DOUBLE | ||
-Wno-strict-aliasing | ||
-Werror | ||
# make non-trivial(but like "trivial") class can reallocate | ||
-Wno-class-memaccess | ||
-Wno-implicit-fallthrough | ||
#-Wconversion | ||
#-Wshadow | ||
-Wno-maybe-uninitialized | ||
-Wwrite-strings # in fact, this is default specified | ||
#cxx standard | ||
-pthread | ||
|
||
# linker opt | ||
-rdynamic | ||
# machine opt | ||
-march=native | ||
) | ||
|
||
# Clang和GCC有些选项是不通用的 | ||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | ||
list(REMOVE_ITEM CXX_FLAGS "-Wno-return-local-addr") | ||
list(REMOVE_ITEM CXX_FLAGS "-rdynamic") | ||
list(APPEND CXX_FLAGS "-Wthread-safety") | ||
endif() | ||
|
||
string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CXX_FLAGS}") | ||
endif () | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
include(GNUInstallDirs) | ||
|
||
function (conzxy_install) | ||
cmake_parse_arguments(PARSE_ARGV 0 CONZXY "" "PROJECT;NAMESPACE" "TARGETS") | ||
|
||
set(project_config_in_file "${CMAKE_CURRENT_LIST_DIR}/cmake/${CONZXY_PROJECT}Config.cmake.in") | ||
set(project_config_out_file "${CMAKE_CURRENT_BINARY_DIR}/${CONZXY_PROJECT}Config.cmake") | ||
set(config_targets_filename "${CONZXY_PROJECT}ConfigTargets.cmake") | ||
set(config_version_file "${CMAKE_CURRENT_BINARY_DIR}/${CONZXY_PROJECT}ConfigVersion.cmake") | ||
set(export_dest_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${CONZXY_PROJECT}") | ||
|
||
# Specify rules of targets | ||
install( | ||
TARGETS ${CONZXY_TARGETS} | ||
EXPORT ${CONZXY_PROJECT} | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" | ||
) | ||
|
||
# Export the ConfigTargets.cmake to build directory | ||
# To make user use find_package() successfully but don't install, | ||
# you can use export(PACKAGE <name>) command to register build dir to | ||
# ~/.cmake/packages/ | ||
export( | ||
EXPORT ${CONZXY_PROJECT} | ||
NAMESPACE ${CONZXY_NAMESPACE}:: | ||
FILE "${CMAKE_CURRENT_BINARY_DIR}/${config_targets_filename}") | ||
|
||
# Generate and Install ConfigTargets.cmake | ||
install(EXPORT ${CONZXY_PROJECT} | ||
DESTINATION "${export_dest_dir}" | ||
NAMESPACE ${CONZXY_NAMESPACE}:: | ||
FILE ${config_targets_filename}) | ||
|
||
include(CMakePackageConfigHelpers) | ||
# Generate Config.cmake and ConfigVersion.cmake | ||
# (<in> <out>) | ||
configure_package_config_file("${project_config_in_file}" "${project_config_out_file}" | ||
INSTALL_DESTINATION "${export_dest_dir}") | ||
write_basic_package_version_file("${config_version_file}" COMPATIBILITY SameMajorVersion) | ||
message(STATUS "Config file path = ${project_config_out_file}") | ||
message(STATUS "ConfigVersion file path = ${config_version_file}") | ||
# Install Config.cmake and ConfigVersion.cmake | ||
install(FILES "${project_config_out_file}" "${config_version_file}" DESTINATION "${export_dest_dir}") | ||
endfunction () | ||
|
||
message(STATUS "CMAKE_INSTALL_INCLUDEDIR: ${CMAKE_INSTALL_INCLUDEDIR}") | ||
message(STATUS "CMAKE_INSTALL_BINDIR: ${CMAKE_INSTALL_BINDIR}") | ||
message(STATUS "CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}") | ||
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# In other platform(eg. windows), generating base library only. | ||
if (UNIX AND NOT APPLE) | ||
message(STATUS "Mmkv on unix/linux/solaris/... platform") | ||
set(MMKV_ON_UNIX ON) | ||
else () | ||
set(MMKV_ON_UNIX OFF) | ||
endif () | ||
|
||
if (WIN32) | ||
message(STATUS "Mmkv on windows") | ||
set(MMKV_ON_WIN ON) | ||
endif () | ||
|
Oops, something went wrong.