Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
brinkqiang committed Dec 27, 2024
1 parent 27b1e83 commit ae9dcc2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 12 deletions.
45 changes: 33 additions & 12 deletions cmake/ModuleCompileOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,17 @@ macro(ModuleSetCompileOptions)

SET(DMOS_NAME "lin")

CHECK_CXX_COMPILER_FLAG("-std=c++20" COMPILER_SUPPORTS_CXX20)
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)
if(COMPILER_SUPPORTS_CXX20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20")
message(STATUS "The compiler has -std=c++20 support.")
elseif(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)
Expand All @@ -178,9 +182,9 @@ macro(ModuleSetCompileOptions)
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)
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 or newer support. Please use a different C++ compiler.")
endif()

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wl,--rpath=./ -Wl,-rpath-link=./lib")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -D_DEBUG")
Expand Down Expand Up @@ -235,11 +239,28 @@ macro(ModuleSetWinCompilerFlags)
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)
MACRO(AddInstall ModuleList)
message(STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
message(STATUS "Install Path: ${CMAKE_INSTALL_PREFIX}/bin")

Message(STATUS "AddInstall ${ModuleList} ...")
IF (WIN32)
INSTALL(TARGETS ${ModuleList}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
ELSE(WIN32)
INCLUDE(GNUInstallDirs)
INSTALL(TARGETS ${ModuleList}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
ENDIF(WIN32)

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(AddInstall)
15 changes: 15 additions & 0 deletions cmake/ModuleImport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ macro(ModuleInclude ModuleName ModulePath)

endmacro(ModuleInclude)

macro(InterfaceImport ModuleName ModulePath DependsLib)
MESSAGE(STATUS "ModuleImport ${ModuleName} ${ModulePath}")

set(${ModuleName}_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${ModulePath})
mark_as_advanced(${ModuleName}_INCLUDE_DIR)
set(${ModuleName}_LIBRARIES ${ModuleName})
mark_as_advanced(${ModuleName}_LIBRARIES)

add_library(${ModuleName} INTERFACE)

target_include_directories(${ModuleName} INTERFACE ${${ModuleName}_INCLUDE_DIR})

TARGET_LINK_LIBRARIES(${ModuleName} ${DependsLib})
endmacro(InterfaceImport)

macro(ModuleImport ModuleName ModulePath)
MESSAGE(STATUS "ModuleImport ${ModuleName} ${ModulePath}")

Expand Down

0 comments on commit ae9dcc2

Please sign in to comment.