cmake_minimum_required(VERSION 3.11) enable_language(CXX) project(generallib) add_subdirectory(general) SET(SRC_SDK sdk_main.c )#生成动态库需要至少包含一个源文件 add_library(generallib STATIC $ ${SRC_SDK}) message("current path is" ${CMAKE_CURRENT_SOURCE_DIR}) IF (WIN32) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") message("clang compiler \r\n") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") message("gcc compiler \r\n") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") message("using asm") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") message("using msvc compiler") endif() endif() # copy header files SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/obj) set(COPYITEM inc) file(GLOB INCLUDES ${PROJECT_SOURCE_DIR}/general/inc/*) file(COPY ${INCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) message("include dir \n" ${INCLUDES}) file(GLOB PatternINCLUDES ${PROJECT_SOURCE_DIR}/general/src/pattern/*) file(COPY ${PatternINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/pattern FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) message( "copy pattern library \n" ${PatternINCLUDES}) file(GLOB EncryptINCLUDES ${PROJECT_SOURCE_DIR}/general/src/encrypt/*.h) file(COPY ${EncryptINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/encrypt FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) file(GLOB MathINCLUDES ${PROJECT_SOURCE_DIR}/general/src/math/*.hpp) message( "copy math library" ${MathINCLUDES}) add_custom_command(TARGET generallib PRE_LINK COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/general/src/math/eigen ${LIBRARY_OUTPUT_PATH}/inc/math/eigen) message( "copy third library \n") file(GLOB THIRD ${PROJECT_SOURCE_DIR}/general/third/include/*) file(COPY ${THIRD} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/third/include/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) message( "copy net \n") file(GLOB NET ${PROJECT_SOURCE_DIR}/general/src/net/*.h) file(COPY ${NET} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) file(GLOB ALGORITHM ${PROJECT_SOURCE_DIR}/general/src/algorithm/*) file(COPY ${ALGORITHM} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)