1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- macro(source_group_by_dir source_files)
- if(MSVC)
- set(sgbd_cur_dir ${CMAKE_CURRENT_SOURCE_DIR})
- foreach(sgbd_file ${${source_files}})
- string(REGEX REPLACE ${sgbd_cur_dir}/\(.*\) \\1 sgbd_fpath ${sgbd_file})
- string(REGEX REPLACE "\(.*\)/.*" \\1 sgbd_group_name ${sgbd_fpath})
- string(COMPARE EQUAL ${sgbd_fpath} ${sgbd_group_name} sgbd_nogroup)
- string(REPLACE "/" "\\" sgbd_group_name ${sgbd_group_name})
- if(sgbd_nogroup)
- set(sgbd_group_name "\\")
- endif(sgbd_nogroup)
- source_group(${sgbd_group_name} FILES ${sgbd_file})
- endforeach(sgbd_file)
- endif(MSVC)
- endmacro()
- macro(rel_source_group_by_dir source_files root_path)
- if(MSVC)
- set(sgbd_cur_dir ${CMAKE_CURRENT_SOURCE_DIR})
- foreach(sgbd_file ${${source_files}})
- file(RELATIVE_PATH rel_file ${root_path} ${sgbd_file})
- string(REGEX REPLACE ${sgbd_cur_dir}/\(.*\) \\1 sgbd_fpath ${rel_file})
- string(REGEX REPLACE "\(.*\)/.*" \\1 sgbd_group_name ${sgbd_fpath})
- string(COMPARE EQUAL ${sgbd_fpath} ${sgbd_group_name} sgbd_nogroup)
- string(REPLACE "/" "\\" sgbd_group_name ${sgbd_group_name})
- if(sgbd_nogroup)
- set(sgbd_group_name "\\")
- endif(sgbd_nogroup)
- source_group(${sgbd_group_name} FILES ${sgbd_file})
- endforeach(sgbd_file)
- endif(MSVC)
- endmacro()
- macro(INSTALL_NUGET target id version)
- if (CMAKE_GENERATOR MATCHES "Visual Studio.*")
- unset(nuget_cmd)
- list(APPEND nuget_cmd install ${id} -Prerelease -Version ${version} -OutputDirectory ${CMAKE_BINARY_DIR}/packages)
- #message("excute nuget install:${nuget_cmd}")
- execute_process(COMMAND ${PROJECT_SOURCE_DIR}/scripts/nuget.exe ${nuget_cmd} ENCODING AUTO)
- target_link_libraries(${target} ${CMAKE_BINARY_DIR}/packages/${id}.${version}/build/native/${id}.targets)
- else()
- message(FATAL_ERROR "INSTALL_NUGET noly use in Visual Studio")
- endif()
- endmacro()
- macro(SET_DIR name path)
- set(${name}_DIR ${path})
- if(EXISTS ${path}/${SYS}/include)
- set(${name}_INCLUDE_DIR ${path}/${SYS}/include)
- else()
- set(${name}_INCLUDE_DIR ${path}/include)
- endif()
- if(EXISTS ${path}/${SYS}/${CPU}/static)
- set(${name}_STATIC_LIB_DIR ${path}/${SYS}/${CPU}/static)
- else()
- set(${name}_STATIC_LIB_DIR ${path}/${SYS}/static)
- ENDIF()
- if(EXISTS ${path}/${SYS}/${CPU}/lib)
- set(${name}_LIB_DIR ${path}/${SYS}/${CPU}/lib)
- set(${name}_LIB_DIR_DEBUG ${path}/${SYS}/${CPU}/lib/Debug)
- set(${name}_LIB_DIR_RELEASE ${path}/${SYS}/${CPU}/lib/Release)
- elseif(EXISTS ${path}/${SYS}/lib)
- set(${name}_LIB_DIR ${path}/${SYS}/lib)
- set(${name}_LIB_DIR_DEBUG ${path}/${SYS}/lib/Debug)
- set(${name}_LIB_DIR_RELEASE ${path}/${SYS}/lib/Release)
- elseif(EXISTS ${path}/library)
- set(${name}_LIB_DIR ${path}/library)
- set(${name}_LIB_DIR_DEBUG ${path}/library/Debug)
- set(${name}_LIB_DIR_RELEASE ${path}/library/Release)
- else()
- set(${name}_LIB_DIR ${path}/lib)
- set(${name}_LIB_DIR_DEBUG ${path}/lib/Debug)
- set(${name}_LIB_DIR_RELEASE ${path}/lib/Release)
- endif()
- IF(MSVC)
- set(${name}_BIN_DIR ${path}/${SYS}/bin)
- set(${name}_BIN_DIR_DEBUG ${path}/${SYS}/bin/Debug)
- set(${name}_BIN_DIR_RELEASE ${path}/${SYS}/bin/Release)
- ELSE()
- set(${name}_BIN_DIR ${path}/${SYS}/lib)
- set(${name}_BIN_DIR_DEBUG ${path}/${SYS}/lib)
- set(${name}_BIN_DIR_RELEASE ${path}/${SYS}/lib)
- ENDIF()
- set(${name}_SRC_DIR ${path}/src)
- endmacro()
|