FrontPage

#stub

External Project

example of CMakeLists.txt

#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 /wd4819 -D_VARIADIC_MAX=10 /MP")
   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-format=ieee")
   endif()
   set(INTRINSIC_SOURCES converter_arm.cpp)

endif() set(HALF_CONVERTER_FILES ${INTRINSIC_SOURCES} converter.cpp converter.hpp)

# 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_VALUE)

   message(STATUS "Downloading ${PROJECT_NAME}")
   get_filename_component(EXTRACT_ARCHIVE_FILE ${FULL_URL} NAME)
   set(${PROJECT_NAME}_FULL_URL "${FULL_URL}")
   set(${PROJECT_NAME}_WORK_DIR "${PACKAGE_ARCHIVE_DIR}")
   set(${PROJECT_NAME}_ARCHIVE_FILE "${PACKAGE_ARCHIVE_DIR}/${EXTRACT_ARCHIVE_FILE}")
   set(${PROJECT_NAME}_UNPACK_DIR "${CMAKE_BINARY_DIR}/third-party/${PROJECT_NAME}-src")
   if(NOT EXISTS ${${PROJECT_NAME}_ARCHIVE_FILE})
   file(
       DOWNLOAD ${FULL_URL} ${${PROJECT_NAME}_ARCHIVE_FILE}
       EXPECTED_MD5 ${MD5_HASH_VALUE} 
   )
   file(MD5 "${${PROJECT_NAME}_ARCHIVE_FILE}" ${PROJECT_NAME}_DOWNLOADED_MD5)
   if(NOT ${${PROJECT_NAME}_DOWNLOADED_MD5} STREQUAL ${MD5_HASH_VALUE})
       message(
           FATAL_ERROR
           "${PROJECT_NAME} MD5 hash match error : ${${PROJECT_NAME}_DOWNLOADED_MD5} (expected: ${MD5_HASH_VALUE})"
       )
   endif(NOT ${${PROJECT_NAME}_DOWNLOADED_MD5} STREQUAL ${MD5_HASH_VALUE})
   endif()
   set(${PROJECT_NAME}_DOWNLOADED_FILE "${${PROJECT_NAME}_ARCHIVE_FILE}")

endmacro(check_and_download)

macro(check_and_add_as_external_project PROJECT_NAME FULL_URL MD5_HASH_VALUE)

   check_and_download(${PROJECT_NAME} ${FULL_URL} ${MD5_HASH_VALUE})
   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}-src" 
   CMAKE_ARGS  "${gtest_cmake_args}" 
   "-DCMAKE_INSTALL_PREFIX=${THIRDPARTY_INSTALL}" 
   ${ARGN}
   )
   SET_TARGET_PROPERTIES(${PROJECT_NAME}_ext PROPERTIES FOLDER "3rdparty")

endmacro(check_and_add_as_external_project)

# gtest check_and_add_as_external_project(gtest

   "https://github.com/google/googletest/archive/release-1.8.0.zip"
   "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.lib") set(GTEST_LIBRARY_DEBUG "${GTEST_LIB_PATH}/gtestd.lib") set(GTEST_MAIN_DEBUG "${GTEST_LIB_PATH}/gtest_maind.lib") include_directories(${GTEST_INCLUDE_DIR}) find_package(Threads) }}


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2017-06-19 (月) 19:05:33