From fac0848e6f121fc9e1e6b48f9b6460b6e469f442 Mon Sep 17 00:00:00 2001 From: brinkqiang Date: Tue, 16 Jan 2024 20:50:21 +0800 Subject: [PATCH 1/5] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b1ab98e..cfa4c28 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,6 @@ TEST(luabasetest, luabasetest) } ``` ## Contacts -[![Join the chat](https://badges.gitter.im/brinkqiang/dmlua/Lobby.svg)](https://gitter.im/brinkqiang/dmlua) ## Thanks gavingqf@126.com From 124307aaeec5fbb931e31ea5b117623bf7a3c0a5 Mon Sep 17 00:00:00 2001 From: brinkqiang Date: Wed, 3 Apr 2024 06:38:40 +0800 Subject: [PATCH 2/5] add --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a649651..165ccfc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ SET(LUA_MODULE lua54) ADD_DEFINITIONS(-DLUA_COMPAT_MODULE -DLUA_COMPAT_APIINTCASTS) -SET (CMAKE_C_STANDARD 89) +#SET (CMAKE_C_STANDARD 89) ShowEnvironment() From 76a44291220eb872dc6000d7465f7e727b2f47f5 Mon Sep 17 00:00:00 2001 From: brinkqiang Date: Wed, 3 Apr 2024 06:45:30 +0800 Subject: [PATCH 3/5] ad --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 165ccfc..7b59267 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,11 +2,12 @@ cmake_minimum_required(VERSION 3.2) PROJECT(dmlua) -INCLUDE(cmake/ModuleImport.cmake) LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +INCLUDE(cmake/ModuleImport.cmake) INCLUDE(cmake/ModuleCompileOptions.cmake) INCLUDE(cmake/LuaModule.cmake) ModuleSetCompileOptions() +ModuleSetWinCompilerFlags() SET(LUA_MODULE lua54) From b8d4ca00c35e0f2734bef4ee0e16342cfdfac6f4 Mon Sep 17 00:00:00 2001 From: brinkqiang Date: Wed, 3 Apr 2024 07:07:55 +0800 Subject: [PATCH 4/5] add --- cmake/ModuleCompileOptions.cmake | 456 +++++++++++++++---------------- 1 file changed, 228 insertions(+), 228 deletions(-) diff --git a/cmake/ModuleCompileOptions.cmake b/cmake/ModuleCompileOptions.cmake index 613d380..bd1f0d6 100644 --- a/cmake/ModuleCompileOptions.cmake +++ b/cmake/ModuleCompileOptions.cmake @@ -1,229 +1,229 @@ - -# Copyright (c) 2018 brinkqiang (brink.qiang@gmail.com) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -macro(ShowEnvironment) - message(STATUS "================================================================================") - get_cmake_property(_variableNames VARIABLES) - foreach (_variableName ${_variableNames}) - message(STATUS "${_variableName}=${${_variableName}}") - endforeach() - - execute_process(COMMAND "${CMAKE_COMMAND}" "-E" "environment") - message(STATUS "================================================================================") -endmacro(ShowEnvironment) - -macro(ModuleSetCompileOptions) - CMAKE_POLICY(SET CMP0022 NEW) - INCLUDE(CheckCXXCompilerFlag) - IF(POLICY CMP0048) - CMAKE_POLICY(SET CMP0048 NEW) - ENDIF() - - SET (CMAKE_C_STANDARD 99) - - IF ("${CMAKE_BUILD_TYPE}" STREQUAL "") - SET(CMAKE_BUILD_TYPE "debug") - ENDIF() - - IF (WIN32) - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/windows) - ENDIF(WIN32) - - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/test) - - IF (WIN32) - LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/bin) - SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin) - SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin) - ELSE(WIN32) - LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) - SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) - SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) - ENDIF(WIN32) - - IF (WIN32) - MESSAGE(STATUS "Now is windows") - - SET(DMOS_NAME "win") - - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") - SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}") - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") - - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") - SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") - - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /OPT:REF /OPT:NOICF /STACK:16777216") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG /OPT:REF /OPT:NOICF /STACK:16777216") - SET(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS}") - LINK_LIBRARIES(Ws2_32) - IF(MSVC) - ADD_DEFINITIONS(/bigobj) - ADD_DEFINITIONS(/DNOMINMAX /DWIN32_LEAN_AND_MEAN=1 /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS) - - ADD_COMPILE_OPTIONS(/W3 /wd4005 /wd4068 /wd4244 /wd4267 /wd4800) - IF (MSVC_VERSION GREATER_EQUAL 1900) - CHECK_CXX_COMPILER_FLAG("/std:c++latest" _cpp_latest_flag_supported) - IF (_cpp_latest_flag_supported) - ADD_COMPILE_OPTIONS("/std:c++latest") - ENDIF() - ENDIF() - ENDIF() - ELSEIF (APPLE) - MESSAGE(STATUS "Now is Apple systems") - - SET(DMOS_NAME "mac") - - CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17) - CHECK_CXX_COMPILER_FLAG("-std=c++1z" COMPILER_SUPPORTS_CXX1Z) - CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) - CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX1Y) - CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) - - if(COMPILER_SUPPORTS_CXX17) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") - message(STATUS "The compiler has -std=c++17 support.") - elseif(COMPILER_SUPPORTS_CXX1Z) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z") - message(STATUS "The compiler has -std=c++1z support.") - elseif(COMPILER_SUPPORTS_CXX14) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") - message(STATUS "The compiler has -std=c++14 support.") - elseif(COMPILER_SUPPORTS_CXX1Y) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y") - message(STATUS "The compiler has -std=c++1y support.") - elseif(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - message(STATUS "The compiler has -std=c++11 support.") - else(COMPILER_SUPPORTS_CXX17) - message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") - endif(COMPILER_SUPPORTS_CXX17) - - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -fPIC") - - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -D_DEBUG") - SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -g") - SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -g") - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -g") - - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -fPIC" ) - - SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG") - SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g") - SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -g") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g") - - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" ) - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") - SET(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS}") - LINK_LIBRARIES() - ELSEIF (UNIX) - MESSAGE(STATUS "Now is UNIX-like OS") - - SET(DMOS_NAME "lin") - - CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17) - CHECK_CXX_COMPILER_FLAG("-std=c++1z" COMPILER_SUPPORTS_CXX1Z) - CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) - CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX1Y) - CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) - - if(COMPILER_SUPPORTS_CXX17) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") - message(STATUS "The compiler has -std=c++17 support.") - elseif(COMPILER_SUPPORTS_CXX1Z) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z") - message(STATUS "The compiler has -std=c++1z support.") - elseif(COMPILER_SUPPORTS_CXX14) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") - message(STATUS "The compiler has -std=c++14 support.") - elseif(COMPILER_SUPPORTS_CXX1Y) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y") - message(STATUS "The compiler has -std=c++1y support.") - elseif(COMPILER_SUPPORTS_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - message(STATUS "The compiler has -std=c++11 support.") - else(COMPILER_SUPPORTS_CXX17) - message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") - endif(COMPILER_SUPPORTS_CXX17) - - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -fPIC -Wl,--rpath=./ -Wl,-rpath-link=./lib") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -D_DEBUG") - SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -g") - SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -g") - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -g") - - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -fPIC -Wl,--rpath=./ -Wl,-rpath-link=./lib") - SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG") - SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g") - SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -g") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g") - - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") - SET(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS}") - - LINK_LIBRARIES(rt dl m) - FIND_PROGRAM(CCACHE_FOUND ccache) - IF(CCACHE_FOUND) - SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) - SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) - ENDIF(CCACHE_FOUND) - ENDIF () -endmacro(ModuleSetCompileOptions) - -macro(ModuleSetWinCompilerFlags) - IF (WIN32) - set(CompilerFlags - CMAKE_CXX_FLAGS - CMAKE_CXX_FLAGS_DEBUG - CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_RELWITHDEBINFO - CMAKE_CXX_FLAGS_MINSIZEREL - CMAKE_C_FLAGS - CMAKE_C_FLAGS_DEBUG - CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_RELWITHDEBINFO - CMAKE_C_FLAGS_MINSIZEREL - ) - foreach(CompilerFlag ${CompilerFlags}) - string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") - endforeach() - ENDIF (WIN32) -endmacro(ModuleSetWinCompilerFlags) - - -MACRO(AddUninstallTarget) -CONFIGURE_FILE( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - IMMEDIATE @ONLY) -ADD_CUSTOM_TARGET(uninstall - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) + +# Copyright (c) 2018 brinkqiang (brink.qiang@gmail.com) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +macro(ShowEnvironment) + message(STATUS "================================================================================") + get_cmake_property(_variableNames VARIABLES) + foreach (_variableName ${_variableNames}) + message(STATUS "${_variableName}=${${_variableName}}") + endforeach() + + execute_process(COMMAND "${CMAKE_COMMAND}" "-E" "environment") + message(STATUS "================================================================================") +endmacro(ShowEnvironment) + +macro(ModuleSetCompileOptions) + CMAKE_POLICY(SET CMP0022 NEW) + INCLUDE(CheckCXXCompilerFlag) + IF(POLICY CMP0048) + CMAKE_POLICY(SET CMP0048 NEW) + ENDIF() + + SET (CMAKE_C_STANDARD 99) + + IF ("${CMAKE_BUILD_TYPE}" STREQUAL "") + SET(CMAKE_BUILD_TYPE "debug") + ENDIF() + + IF (WIN32) + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/windows) + ENDIF(WIN32) + + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/test) + + IF (WIN32) + LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/bin) + SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin) + SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin) + ELSE(WIN32) + LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) + SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) + SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) + ENDIF(WIN32) + + IF (WIN32) + MESSAGE(STATUS "Now is windows") + + SET(DMOS_NAME "win") + + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}") + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /OPT:REF /OPT:NOICF /STACK:16777216") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG /OPT:REF /OPT:NOICF /STACK:16777216") + SET(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS}") + LINK_LIBRARIES(Ws2_32) + IF(MSVC) + ADD_DEFINITIONS(/bigobj) + ADD_DEFINITIONS(/DNOMINMAX /DWIN32_LEAN_AND_MEAN=1 /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS) + + ADD_COMPILE_OPTIONS(/W3 /wd4005 /wd4068 /wd4244 /wd4267 /wd4800) + IF (MSVC_VERSION GREATER_EQUAL 1900) + CHECK_CXX_COMPILER_FLAG("/std:c++latest" _cpp_latest_flag_supported) + IF (_cpp_latest_flag_supported) + ADD_COMPILE_OPTIONS("/std:c++latest") + ENDIF() + ENDIF() + ENDIF() + ELSEIF (APPLE) + MESSAGE(STATUS "Now is Apple systems") + + SET(DMOS_NAME "mac") + + CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17) + CHECK_CXX_COMPILER_FLAG("-std=c++1z" COMPILER_SUPPORTS_CXX1Z) + CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) + CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX1Y) + CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) + + if(COMPILER_SUPPORTS_CXX17) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") + message(STATUS "The compiler has -std=c++17 support.") + elseif(COMPILER_SUPPORTS_CXX1Z) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z") + message(STATUS "The compiler has -std=c++1z support.") + elseif(COMPILER_SUPPORTS_CXX14) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + message(STATUS "The compiler has -std=c++14 support.") + elseif(COMPILER_SUPPORTS_CXX1Y) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y") + message(STATUS "The compiler has -std=c++1y support.") + elseif(COMPILER_SUPPORTS_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + message(STATUS "The compiler has -std=c++11 support.") + else(COMPILER_SUPPORTS_CXX17) + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") + endif(COMPILER_SUPPORTS_CXX17) + + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -fPIC") + + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -D_DEBUG") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -g") + SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -g") + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -g") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -fPIC" ) + + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g") + SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -g") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g") + + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" ) + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") + SET(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS}") + LINK_LIBRARIES() + ELSEIF (UNIX) + MESSAGE(STATUS "Now is UNIX-like OS") + + SET(DMOS_NAME "lin") + + CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17) + CHECK_CXX_COMPILER_FLAG("-std=c++1z" COMPILER_SUPPORTS_CXX1Z) + CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) + CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX1Y) + CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) + + if(COMPILER_SUPPORTS_CXX17) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") + message(STATUS "The compiler has -std=c++17 support.") + elseif(COMPILER_SUPPORTS_CXX1Z) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z") + message(STATUS "The compiler has -std=c++1z support.") + elseif(COMPILER_SUPPORTS_CXX14) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + message(STATUS "The compiler has -std=c++14 support.") + elseif(COMPILER_SUPPORTS_CXX1Y) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y") + message(STATUS "The compiler has -std=c++1y support.") + elseif(COMPILER_SUPPORTS_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + message(STATUS "The compiler has -std=c++11 support.") + else(COMPILER_SUPPORTS_CXX17) + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") + endif(COMPILER_SUPPORTS_CXX17) + + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -fPIC -Wl,--rpath=./ -Wl,-rpath-link=./lib -fprofile-arcs") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -D_DEBUG") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -g") + SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -g") + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -g") + + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -fPIC -Wl,--rpath=./ -Wl,-rpath-link=./lib -fprofile-arcs") + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g") + SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -g") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g") + + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") + SET(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS}") + + LINK_LIBRARIES(rt dl m) + FIND_PROGRAM(CCACHE_FOUND ccache) + IF(CCACHE_FOUND) + SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + ENDIF(CCACHE_FOUND) + ENDIF () +endmacro(ModuleSetCompileOptions) + +macro(ModuleSetWinCompilerFlags) + IF (WIN32) + set(CompilerFlags + CMAKE_CXX_FLAGS + CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS_MINSIZEREL + CMAKE_C_FLAGS + CMAKE_C_FLAGS_DEBUG + CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_C_FLAGS_MINSIZEREL + ) + foreach(CompilerFlag ${CompilerFlags}) + string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") + endforeach() + ENDIF (WIN32) +endmacro(ModuleSetWinCompilerFlags) + + +MACRO(AddUninstallTarget) +CONFIGURE_FILE( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) +ADD_CUSTOM_TARGET(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) ENDMACRO(AddUninstallTarget) \ No newline at end of file From 1b79eee8ec23116afec47e873bb2abdbac55fca9 Mon Sep 17 00:00:00 2001 From: brinkqiang Date: Tue, 30 Apr 2024 12:30:31 +0800 Subject: [PATCH 5/5] ADD --- cmake/ModuleImport.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/ModuleImport.cmake b/cmake/ModuleImport.cmake index 7e9147c..10db384 100644 --- a/cmake/ModuleImport.cmake +++ b/cmake/ModuleImport.cmake @@ -195,8 +195,8 @@ macro(DllImport ModuleName ModulePath) ENDIF(WIN32) IF (WIN32) - IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${ModulePath}/${ModuleName}_module.def) - ADD_LIBRARY(${ModuleName} SHARED ${LIB_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/${ModulePath}/${ModuleName}_module.def) + IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${ModulePath}/${ModuleName}.def) + ADD_LIBRARY(${ModuleName} SHARED ${LIB_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/${ModulePath}/${ModuleName}.def) ELSE() ADD_LIBRARY(${ModuleName} SHARED ${LIB_SOURCES}) ENDIF()