gtest and cmake
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[FrontPage]]
#stub
-If you have a code, do you have a test of the code ?
-This page describes how to add gtest using cmake at "bui...
-あなたの手元のコードにテストは書かれていますか?
-このページではcmakeを使って、ビルド時にgtestを追加する方...
#contents
*External Project [#q0c207de]
-in cmake, you may build some project/program/library usi...
-Also, you may download some library using cmake
-Combining this, it will allow you to "download and build...
*example of CMakeLists.txt [#u8c925cb]
#geshi(cmake){{
cmake_minimum_required(VERSION 2.8)
project(softwareFp16)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# detect the platform
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
set(ARM 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64)")
set(AARCH64 1)
else ()
set(X86 1)
endif()
if (X86)
message(STATUS "detected x86 or x86_64 architecture")
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX...
endif()
set(INTRINSIC_SOURCES converter_x86.cpp)
elseif (AARCH64)
message(STATUS "detected ARM 64bit architecture")
set(INTRINSIC_SOURCES converter_arm.cpp)
elseif (ARM)
message(STATUS "detected ARM architecture")
if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfp16-fo...
endif()
set(INTRINSIC_SOURCES converter_arm.cpp)
endif()
set(HALF_CONVERTER_FILES ${INTRINSIC_SOURCES} converter.c...
# gtest
set(PACKAGE_ARCHIVE_DIR "${CMAKE_SOURCE_DIR}/packages")
set(THIRDPARTY_INSTALL "${CMAKE_BINARY_DIR}/third-party")
include(ExternalProject)
macro(check_and_download PROJECT_NAME FULL_URL MD5_HASH_V...
message(STATUS "Downloading ${PROJECT_NAME}")
get_filename_component(EXTRACT_ARCHIVE_FILE ${FULL_UR...
set(${PROJECT_NAME}_FULL_URL "${FULL_URL}")
set(${PROJECT_NAME}_WORK_DIR "${PACKAGE_ARCHIVE_DIR}")
set(${PROJECT_NAME}_ARCHIVE_FILE "${PACKAGE_ARCHIVE_D...
set(${PROJECT_NAME}_UNPACK_DIR "${CMAKE_BINARY_DIR}/t...
if(NOT EXISTS ${${PROJECT_NAME}_ARCHIVE_FILE})
file(
DOWNLOAD ${FULL_URL} ${${PROJECT_NAME}_ARCHIVE_FI...
EXPECTED_MD5 ${MD5_HASH_VALUE}
)
file(MD5 "${${PROJECT_NAME}_ARCHIVE_FILE}" ${PROJECT_...
if(NOT ${${PROJECT_NAME}_DOWNLOADED_MD5} STREQUAL ${M...
message(
FATAL_ERROR
"${PROJECT_NAME} MD5 hash match error : ${${P...
)
endif(NOT ${${PROJECT_NAME}_DOWNLOADED_MD5} STREQUAL ...
endif()
set(${PROJECT_NAME}_DOWNLOADED_FILE "${${PROJECT_NAME...
endmacro(check_and_download)
macro(check_and_add_as_external_project PROJECT_NAME FULL...
check_and_download(${PROJECT_NAME} ${FULL_URL} ${MD5_...
ExternalProject_Add(${PROJECT_NAME}_ext
URL "${${PROJECT_NAME}_ARCHIVE_FILE}"
URL_HASH MD5=${MD5_HASH_VALUE}
BINARY_DIR "${THIRDPARTY_INSTALL}/${PROJECT_NAME}"
SOURCE_DIR "${THIRDPARTY_INSTALL}/${PROJECT_NAME}-sr...
CMAKE_ARGS "${gtest_cmake_args}"
"-DCMAKE_INSTALL_PREFIX=${THIRDPARTY_INSTALL}"
${ARGN}
)
SET_TARGET_PROPERTIES(${PROJECT_NAME}_ext PROPERTIES ...
endmacro(check_and_add_as_external_project)
# gtest
check_and_add_as_external_project(gtest
"https://github.com/google/googletest/archive/release...
"adfafc8512ab65fd3cf7955ef0100ff5"
"-DBUILD_GMOCK=OFF"
"-DBUILD_GTEST=ON"
"-DCMAKE_DEBUG_POSTFIX=d"
)
set(GTEST_INCLUDE_DIR "${THIRDPARTY_INSTALL}/include")
set(GTEST_LIB_PATH "${THIRDPARTY_INSTALL}/lib")
set(GTEST_LIBRARY_RELEASE "${GTEST_LIB_PATH}/gtest.lib")
set(GTEST_MAIN_RELEASE "${GTEST_LIB_PATH}/gtest_main.l...
set(GTEST_LIBRARY_DEBUG "${GTEST_LIB_PATH}/gtestd.lib")
set(GTEST_MAIN_DEBUG "${GTEST_LIB_PATH}/gtest_maind....
include_directories(${GTEST_INCLUDE_DIR})
find_package(Threads)
}}
-let's explain one by one
#geshi(cmake){{
include(ExternalProject)
}}
--what ever you do, you'll need to include ExternalProject
--now you may use ExternalProject_add command
-
終了行:
[[FrontPage]]
#stub
-If you have a code, do you have a test of the code ?
-This page describes how to add gtest using cmake at "bui...
-あなたの手元のコードにテストは書かれていますか?
-このページではcmakeを使って、ビルド時にgtestを追加する方...
#contents
*External Project [#q0c207de]
-in cmake, you may build some project/program/library usi...
-Also, you may download some library using cmake
-Combining this, it will allow you to "download and build...
*example of CMakeLists.txt [#u8c925cb]
#geshi(cmake){{
cmake_minimum_required(VERSION 2.8)
project(softwareFp16)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# detect the platform
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
set(ARM 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64)")
set(AARCH64 1)
else ()
set(X86 1)
endif()
if (X86)
message(STATUS "detected x86 or x86_64 architecture")
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX...
endif()
set(INTRINSIC_SOURCES converter_x86.cpp)
elseif (AARCH64)
message(STATUS "detected ARM 64bit architecture")
set(INTRINSIC_SOURCES converter_arm.cpp)
elseif (ARM)
message(STATUS "detected ARM architecture")
if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfp16-fo...
endif()
set(INTRINSIC_SOURCES converter_arm.cpp)
endif()
set(HALF_CONVERTER_FILES ${INTRINSIC_SOURCES} converter.c...
# gtest
set(PACKAGE_ARCHIVE_DIR "${CMAKE_SOURCE_DIR}/packages")
set(THIRDPARTY_INSTALL "${CMAKE_BINARY_DIR}/third-party")
include(ExternalProject)
macro(check_and_download PROJECT_NAME FULL_URL MD5_HASH_V...
message(STATUS "Downloading ${PROJECT_NAME}")
get_filename_component(EXTRACT_ARCHIVE_FILE ${FULL_UR...
set(${PROJECT_NAME}_FULL_URL "${FULL_URL}")
set(${PROJECT_NAME}_WORK_DIR "${PACKAGE_ARCHIVE_DIR}")
set(${PROJECT_NAME}_ARCHIVE_FILE "${PACKAGE_ARCHIVE_D...
set(${PROJECT_NAME}_UNPACK_DIR "${CMAKE_BINARY_DIR}/t...
if(NOT EXISTS ${${PROJECT_NAME}_ARCHIVE_FILE})
file(
DOWNLOAD ${FULL_URL} ${${PROJECT_NAME}_ARCHIVE_FI...
EXPECTED_MD5 ${MD5_HASH_VALUE}
)
file(MD5 "${${PROJECT_NAME}_ARCHIVE_FILE}" ${PROJECT_...
if(NOT ${${PROJECT_NAME}_DOWNLOADED_MD5} STREQUAL ${M...
message(
FATAL_ERROR
"${PROJECT_NAME} MD5 hash match error : ${${P...
)
endif(NOT ${${PROJECT_NAME}_DOWNLOADED_MD5} STREQUAL ...
endif()
set(${PROJECT_NAME}_DOWNLOADED_FILE "${${PROJECT_NAME...
endmacro(check_and_download)
macro(check_and_add_as_external_project PROJECT_NAME FULL...
check_and_download(${PROJECT_NAME} ${FULL_URL} ${MD5_...
ExternalProject_Add(${PROJECT_NAME}_ext
URL "${${PROJECT_NAME}_ARCHIVE_FILE}"
URL_HASH MD5=${MD5_HASH_VALUE}
BINARY_DIR "${THIRDPARTY_INSTALL}/${PROJECT_NAME}"
SOURCE_DIR "${THIRDPARTY_INSTALL}/${PROJECT_NAME}-sr...
CMAKE_ARGS "${gtest_cmake_args}"
"-DCMAKE_INSTALL_PREFIX=${THIRDPARTY_INSTALL}"
${ARGN}
)
SET_TARGET_PROPERTIES(${PROJECT_NAME}_ext PROPERTIES ...
endmacro(check_and_add_as_external_project)
# gtest
check_and_add_as_external_project(gtest
"https://github.com/google/googletest/archive/release...
"adfafc8512ab65fd3cf7955ef0100ff5"
"-DBUILD_GMOCK=OFF"
"-DBUILD_GTEST=ON"
"-DCMAKE_DEBUG_POSTFIX=d"
)
set(GTEST_INCLUDE_DIR "${THIRDPARTY_INSTALL}/include")
set(GTEST_LIB_PATH "${THIRDPARTY_INSTALL}/lib")
set(GTEST_LIBRARY_RELEASE "${GTEST_LIB_PATH}/gtest.lib")
set(GTEST_MAIN_RELEASE "${GTEST_LIB_PATH}/gtest_main.l...
set(GTEST_LIBRARY_DEBUG "${GTEST_LIB_PATH}/gtestd.lib")
set(GTEST_MAIN_DEBUG "${GTEST_LIB_PATH}/gtest_maind....
include_directories(${GTEST_INCLUDE_DIR})
find_package(Threads)
}}
-let's explain one by one
#geshi(cmake){{
include(ExternalProject)
}}
--what ever you do, you'll need to include ExternalProject
--now you may use ExternalProject_add command
-
ページ名: