Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
47150d4d
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
47150d4d
编写于
5月 08, 2017
作者:
L
Liu Yiqun
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'cmake_protobuf' of
https://github.com/Xreki/Paddle
into cmake_protobuf
上级
5b41fe42
ab9c9434
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
452 addition
and
60 deletion
+452
-60
CMakeLists.txt
CMakeLists.txt
+2
-6
cmake/cross_compiling/android.cmake
cmake/cross_compiling/android.cmake
+191
-0
cmake/cross_compiling/host.cmake
cmake/cross_compiling/host.cmake
+49
-0
cmake/cross_compiling/raspberry_pi.cmake
cmake/cross_compiling/raspberry_pi.cmake
+84
-0
cmake/external/openblas.cmake
cmake/external/openblas.cmake
+30
-14
cmake/external/protobuf.cmake
cmake/external/protobuf.cmake
+69
-37
cmake/system.cmake
cmake/system.cmake
+27
-3
未找到文件。
CMakeLists.txt
浏览文件 @
47150d4d
...
...
@@ -12,17 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License
cmake_minimum_required
(
VERSION 3.0
)
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake"
)
set
(
PROJ_ROOT
${
CMAKE_CURRENT_SOURCE_DIR
}
)
include
(
system
)
if
(
ANDROID
)
cmake_minimum_required
(
VERSION 3.7
)
else
()
cmake_minimum_required
(
VERSION 3.0
)
endif
()
project
(
paddle CXX C
)
find_package
(
Sphinx
)
...
...
cmake/cross_compiling/android.cmake
0 → 100644
浏览文件 @
47150d4d
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This is a toolchain file for cross-compiling for Android, and the
# configuration refers to the open-source resposity:
# https://github.com/taka-no-me/android-cmake
# Most of the variables are compatible with that used in
# https://developer.android.com/ndk/guides/cmake.html
# The supported variables are listed belows:
#
# ANDROID_STANDALONE_TOOLCHAIN
# ANDROID_ABI
# ANDROID_NATIVE_API_LEVEL
# ANDROID_ARM_MODE
# ANDROID_ARM_NEON
#
# For CMake >= 3.7.0, all the settings will be delivered to CMake system
# variables to let CMake do the cross-compiling configurations itself.
# More detail of cross-compiling settings
# https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html
IF
(
NOT ANDROID
)
return
()
ENDIF
()
# check the exist of android standalone toolchain
IF
(
NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN
)
SET
(
ANDROID_STANDALONE_TOOLCHAIN $ENV{ANDROID_STANDALONE_TOOLCHAIN}
CACHE PATH
"Folder holds the standalone toolchain of Android NDK"
)
ENDIF
()
IF
(
NOT ANDROID_STANDALONE_TOOLCHAIN
)
MESSAGE
(
WARNING
"It is recommended to set ANDROID_STANDALONE_TOOLCHAIN to "
"use a standalone toolchain.
\n
"
"To cross-compile for Android, you need to:
\n
"
"1. Download an Android NDK from"
" https://developer.android.com/ndk/downloads/index.html
\n
"
"2. Setup a standalone toolchain"
"https://developer.android.google.cn/ndk/guides/standalone_toolchain.html?hl=zh-cn
\n
"
)
ENDIF
()
IF
(
NOT DEFINED CMAKE_SYSTEM_VERSION AND ANDROID_NATIVE_API_LEVEL
)
IF
(
ANDROID_NATIVE_API_LEVEL MATCHES
"^android-[0-9]+$"
)
STRING
(
REPLACE
"android-"
""
CMAKE_SYSTEM_VERSION
"
${
CMAKE_MATCH_0
}
"
)
ELSEIF
(
ANDROID_NATIVE_API_LEVEL MATCHES
"^[0-9]+$"
)
SET
(
CMAKE_SYSTEM_VERSION
${
ANDROID_NATIVE_API_LEVEL
}
)
ENDIF
()
ENDIF
()
IF
(
NOT DEFINED ANDROID_ABI
)
SET
(
ANDROID_ABI
"armeabi-v7a"
)
ENDIF
()
IF
(
NOT DEFINED ANDROID_ARM_MODE
)
SET
(
ANDROID_ARM_MODE ON
)
ENDIF
()
IF
(
ANDROID_ARM_MODE
)
SET
(
ANDROID_ARM_MODE_NAME
"arm"
)
ELSE
(
ANDROID_ARM_MODE
)
SET
(
ANDROID_ARM_MODE_NAME
"thumb"
)
ENDIF
(
ANDROID_ARM_MODE
)
IF
(
NOT DEFINED ANDROID_ARM_NEON
)
SET
(
ANDROID_ARM_NEON ON
)
ENDIF
()
IF
(
"
${
CMAKE_VERSION
}
"
VERSION_LESS
"3.7.0"
)
IF
(
"
${
CMAKE_VERSION
}
"
VERSION_LESS
"3.1.0"
)
SET
(
CMAKE_SYSTEM_NAME
"Linux"
)
ENDIF
()
MESSAGE
(
WARNING
"It is recommended to use CMake >= 3.7.0 (current version: "
"
${
CMAKE_VERSION
}
), when cross-compiling for Android."
)
IF
(
ANDROID_STANDALONE_TOOLCHAIN
)
SET
(
CMAKE_SYSROOT
"
${
ANDROID_STANDALONE_TOOLCHAIN
}
/sysroot"
)
IF
(
NOT CMAKE_SYSTEM_VERSION
)
SET
(
ANDROID_STANDALONE_TOOLCHAIN_API
""
)
SET
(
ANDROID_API_LEVEL_H_REGEX
"^[
\t
]*#[
\t
]*define[
\t
]+__ANDROID_API__[
\t
]+([0-9]+)"
)
FILE
(
STRINGS
"
${
ANDROID_STANDALONE_TOOLCHAIN
}
/sysroot/usr/include/android/api-level.h"
ANDROID_API_LEVEL_H_CONTENT REGEX
"
${
ANDROID_API_LEVEL_H_REGEX
}
"
)
IF
(
ANDROID_API_LEVEL_H_CONTENT MATCHES
"
${
ANDROID_API_LEVEL_H_REGEX
}
"
)
SET
(
ANDROID_STANDALONE_TOOLCHAIN_API
"
${
CMAKE_MATCH_1
}
"
)
ENDIF
()
SET
(
CMAKE_SYSTEM_VERSION
${
ANDROID_STANDALONE_TOOLCHAIN_API
}
)
ENDIF
()
# Toolchain
SET
(
ANDROID_TOOLCHAIN
"gcc"
)
SET
(
ANDROID_TOOLCHAIN_ROOT
${
ANDROID_STANDALONE_TOOLCHAIN
}
)
IF
(
ANDROID_ABI MATCHES
"^armeabi(-v7a)?$"
)
SET
(
ANDROID_TOOLCHAIN_NAME arm-linux-androideabi
)
IF
(
ANDROID_ABI STREQUAL
"armeabi"
)
SET
(
CMAKE_SYSTEM_PROCESSOR armv5te
)
ELSEIF
(
ANDROID_ABI STREQUAL
"armeabi-v7a"
)
SET
(
CMAKE_SYSTEM_PROCESSOR armv7-a
)
ENDIF
()
ENDIF
()
SET
(
ANDROID_TOOLCHAIN_PREFIX
"
${
ANDROID_TOOLCHAIN_ROOT
}
/bin/
${
ANDROID_TOOLCHAIN_NAME
}
-"
)
ENDIF
()
# C compiler
IF
(
NOT CMAKE_C_COMPILER
)
SET
(
ANDROID_C_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
gcc"
)
ELSE
()
GET_FILENAME_COMPONENT
(
ANDROID_C_COMPILER
${
CMAKE_C_COMPILER
}
PROGRAM
)
ENDIF
()
IF
(
NOT EXISTS
${
ANDROID_C_COMPILER
}
)
MESSAGE
(
FATAL_ERROR
"Cannot find C compiler:
${
ANDROID_C_COMPILER
}
"
)
ENDIF
()
# CXX compiler
IF
(
NOT CMAKE_CXX_COMPILER
)
SET
(
ANDROID_CXX_COMPILER
"
${
ANDROID_TOOLCHAIN_PREFIX
}
g++"
)
ELSE
()
GET_FILENAME_COMPONENT
(
ANDROID_CXX_COMPILER
${
CMAKE_CXX_COMPILER
}
PROGRAM
)
ENDIF
()
IF
(
NOT EXISTS
${
ANDROID_CXX_COMPILER
}
)
MESSAGE
(
FATAL_ERROR
"Cannot find CXX compiler:
${
ANDROID_CXX_COMPILER
}
"
)
ENDIF
()
SET
(
CMAKE_C_COMPILER
${
ANDROID_C_COMPILER
}
CACHE PATH
"C compiler"
FORCE
)
SET
(
CMAKE_CXX_COMPILER
${
ANDROID_CXX_COMPILER
}
CACHE PATH
"CXX compiler"
FORCE
)
# Toolchain and ABI specific flags.
SET
(
ANDROID_COMPILER_FLAGS
"-ffunction-sections -fdata-sections -finline-limit=64"
)
SET
(
ANDROID_LINKER_FLAGS
"-Wl,--gc-sections"
)
IF
(
ANDROID_ABI STREQUAL
"armeabi"
)
LIST
(
APPEND ANDROID_COMPILER_FLAGS
-march=armv5te
-mtune=xscale
-msoft-float
)
ENDIF
()
IF
(
ANDROID_ABI STREQUAL
"armeabi-v7a"
)
LIST
(
APPEND ANDROID_COMPILER_FLAGS
-march=armv7-a
-mfloat-abi=softfp
)
IF
(
ANDROID_ARM_NEON
)
LIST
(
APPEND ANDROID_COMPILER_FLAGS -mfpu=neon
)
ELSE
()
LIST
(
APPEND ANDROID_COMPILER_FLAGS -mfpu=vfpv3-d16
)
ENDIF
()
LIST
(
APPEND ANDROID_LINKER_FLAGS -Wl,--fix-cortex-a8
)
ENDIF
()
IF
(
ANDROID_ABI MATCHES
"^armeabi(-v7a)?$"
)
IF
(
ANDROID_ARM_MODE
)
LIST
(
APPEND ANDROID_COMPILER_FLAGS -marm
)
ELSE
()
LIST
(
APPEND ANDROID_COMPILER_FLAGS -mthumb
)
ENDIF
()
ENDIF
()
STRING
(
REPLACE
";"
" "
ANDROID_COMPILER_FLAGS
"
${
ANDROID_COMPILER_FLAGS
}
"
)
STRING
(
REPLACE
";"
" "
ANDROID_LINKER_FLAGS
"
${
ANDROID_LINKER_FLAGS
}
"
)
SET
(
CMAKE_C_FLAGS
"
${
ANDROID_COMPILER_FLAGS
}
${
CMAKE_C_FLAGS
}
"
CACHE STRING
"C flags"
)
SET
(
CMAKE_CXX_FLAGS
"
${
ANDROID_COMPILER_FLAGS
}
${
CMAKE_CXX_FLAGS
}
"
CACHE STRING
"CXX flags"
)
SET
(
CMAKE_SHARED_LINKER_FLAGS
"
${
ANDROID_LINKER_FLAGS
}
${
CMAKE_SHARED_LINKER_FLAGS
}
"
CACHE STRING
"shared linker flags"
)
SET
(
CMAKE_POSITION_INDEPENDENT_CODE TRUE
)
SET
(
CMAKE_EXE_LINKER_FLAGS
"-pie -fPIE
${
ANDROID_LINKER_FLAGS
}
${
CMAKE_EXE_LINKER_FLAGS
}
"
CACHE STRING
"executable linker flags"
)
MESSAGE
(
STATUS
"Android: Targeting API '
${
CMAKE_SYSTEM_VERSION
}
' "
"with architecture '
${
ANDROID_ARM_MODE_NAME
}
', "
"ABI '
${
ANDROID_ABI
}
', and processor '
${
CMAKE_SYSTEM_PROCESSOR
}
'"
)
MESSAGE
(
STATUS
"System CMAKE_C_FLAGS: "
${
CMAKE_C_FLAGS
}
)
MESSAGE
(
STATUS
"System CMAKE_CXX_FLAGS: "
${
CMAKE_CXX_FLAGS
}
)
ELSE
()
IF
(
ANDROID_STANDALONE_TOOLCHAIN
)
SET
(
CMAKE_ANDROID_STANDALONE_TOOLCHAIN
${
ANDROID_STANDALONE_TOOLCHAIN
}
)
ENDIF
()
SET
(
CMAKE_ANDROID_ARCH_ABI
${
ANDROID_ABI
}
)
SET
(
CMAKE_ANDROID_ARM_MODE
${
ANDROID_ARM_MODE
}
)
SET
(
CMAKE_ANDROID_ARM_NEON
${
ANDROID_ARM_NEON
}
)
ENDIF
()
cmake/cross_compiling/host.cmake
0 → 100644
浏览文件 @
47150d4d
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# find host C compiler
IF
(
HOST_C_COMPILER
)
SET
(
HOST_C_COMPILER_NAME
${
HOST_C_COMPILER
}
)
ELSEIF
(
NOT $ENV{CC} STREQUAL
""
)
SET
(
HOST_C_COMPILER_NAME $ENV{CC}
)
ELSE
()
SET
(
HOST_C_COMPILER_NAME cc
)
ENDIF
()
GET_FILENAME_COMPONENT
(
HOST_C_COMPILER_PATH
${
HOST_C_COMPILER_NAME
}
PROGRAM
)
IF
(
NOT HOST_C_COMPILER_PATH OR NOT EXISTS
${
HOST_C_COMPILER_PATH
}
)
MESSAGE
(
FATAL_ERROR
"Cannot find host C compiler, set host C compiler:
\n
"
"
\t
cmake .. -DHOST_C_COMPILER=..."
)
ENDIF
()
# find host CXX compiler
IF
(
HOST_CXX_COMPILER
)
SET
(
HOST_CXX_COMPILER_NAME
${
HOST_CXX_COMPILER
}
)
ELSEIF
(
NOT $ENV{CXX} STREQUAL
""
)
SET
(
HOST_CXX_COMPILER_NAME $ENV{CXX}
)
ELSE
()
SET
(
HOST_CXX_COMPILER_NAME c++
)
ENDIF
()
GET_FILENAME_COMPONENT
(
HOST_CXX_COMPILER_PATH
${
HOST_CXX_COMPILER_NAME
}
PROGRAM
)
IF
(
NOT HOST_CXX_COMPILER_PATH OR NOT EXISTS
${
HOST_CXX_COMPILER_PATH
}
)
MESSAGE
(
FATAL_ERROR
"Cannot find host CXX compiler, set host CXX compiler:
\n
"
"
\t
cmake .. -DHOST_CXX_COMPILER=..."
)
ENDIF
()
SET
(
HOST_C_COMPILER
${
HOST_C_COMPILER_PATH
}
CACHE PATH
"Host C compiler"
)
SET
(
HOST_CXX_COMPILER
${
HOST_CXX_COMPILER_PATH
}
CACHE PATH
"Host CXX compiler"
)
MESSAGE
(
STATUS
"Found host C compiler: "
${
HOST_C_COMPILER
}
)
MESSAGE
(
STATUS
"Found host CXX compiler: "
${
HOST_CXX_COMPILER
}
)
cmake/cross_compiling/raspberry_pi.cmake
0 → 100644
浏览文件 @
47150d4d
# Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This is a toolchain file for cross-compiling for Raspberry Pi.
# The supported variables are listed belows:
#
# RPI_TOOLCHAIN
# RPI_ARM_NEON
#
# Also you can set CMAKE_C/CXX_COMPILER yourself, through cmake arguments.
IF
(
NOT RPI
)
return
()
ENDIF
()
SET
(
CMAKE_SYSTEM_NAME Linux
)
SET
(
CMAKE_SYSTEM_VERSION 1
)
SET
(
CMAKE_SYSTEM_PROCESSOR arm
)
# check the exist of raspberry pi toolchain
IF
(
NOT DEFINED RPI_TOOLCHAIN
)
SET
(
RPI_TOOLCHAIN $ENV{RPI_TOOLCHAIN}
CACHE PATH
"Folder holds the toolchain of Raspberr Pi"
)
ENDIF
()
IF
(
NOT RPI_TOOLCHAIN
)
MESSAGE
(
WARNING
"It is recommended to set RPI_TOOLCHAIN to use toolchain.
\n
"
"To cross-compile for Raspberry Pi, you need to download the tools using:
\n
"
" git clone https://github.com/raspberrypi/tools
\n
"
)
ENDIF
()
IF
(
NOT DEFINED RPI_ARM_NEON
)
SET
(
RPI_ARM_NEON ON
)
ENDIF
()
IF
(
RPI_TOOLCHAIN
)
SET
(
RPI_TOOLCHAIN_ROOT
${
RPI_TOOLCHAIN
}
)
IF
(
RPI_TOOLCHAIN_ROOT MATCHES
"gcc-linaro-arm-linux-gnueabihf-raspbian(-x64)?$"
)
# gcc-linaro-arm-linux-gnueabihf-raspbian
# gcc-linaro-arm-linux-gnueabihf-raspbian-x64
SET
(
RPI_TOOLCHAIN_NAME arm-linux-gnueabihf
)
ENDIF
()
SET
(
RPI_TOOLCHAIN_PREFIX
"
${
RPI_TOOLCHAIN_ROOT
}
/bin/
${
RPI_TOOLCHAIN_NAME
}
-"
)
ENDIF
()
# C compiler
IF
(
NOT CMAKE_C_COMPILER
)
SET
(
RPI_C_COMPILER
"
${
RPI_TOOLCHAIN_PREFIX
}
gcc"
)
ELSE
()
GET_FILENAME_COMPONENT
(
RPI_C_COMPILER
${
CMAKE_C_COMPILER
}
PROGRAM
)
ENDIF
()
IF
(
NOT EXISTS
${
RPI_C_COMPILER
}
)
MESSAGE
(
FATAL_ERROR
"Cannot find C compiler:
${
RPI_C_COMPILER
}
"
)
ENDIF
()
# CXX compiler
IF
(
NOT CMAKE_CXX_COMPILER
)
SET
(
RPI_CXX_COMPILER
"
${
RPI_TOOLCHAIN_PREFIX
}
g++"
)
ELSE
()
GET_FILENAME_COMPONENT
(
RPI_CXX_COMPILER
${
CMAKE_CXX_COMPILER
}
PROGRAM
)
ENDIF
()
IF
(
NOT EXISTS
${
RPI_CXX_COMPILER
}
)
MESSAGE
(
FATAL_ERROR
"Cannot find CXX compiler:
${
RPI_CXX_COMPILER
}
"
)
ENDIF
()
SET
(
CMAKE_C_COMPILER
${
RPI_C_COMPILER
}
CACHE PATH
"C compiler"
FORCE
)
SET
(
CMAKE_CXX_COMPILER
${
RPI_CXX_COMPILER
}
CACHE PATH
"CXX compiler"
FORCE
)
IF
(
RPI_ARM_NEON
)
SET
(
RPI_C_FLAGS
"
${
RPI_C_FLAGS
}
-mfpu=neon"
)
ENDIF
()
SET
(
CMAKE_C_FLAGS
"
${
RPI_C_FLAGS
}
${
CMAKE_C_FLAGS
}
"
CACHE STRING
"C flags"
)
SET
(
CMAKE_CXX_FLAGS
"
${
RPI_C_FLAGS
}
${
CMAKE_CXX_FLAGS
}
"
CACHE STRING
"CXX flags"
)
cmake/external/openblas.cmake
浏览文件 @
47150d4d
...
...
@@ -21,36 +21,52 @@ IF(NOT ${CBLAS_FOUND})
SET
(
CBLAS_INSTALL_DIR
${
THIRD_PARTY_PATH
}
/install/openblas
)
SET
(
CBLAS_INC_DIR
"
${
CBLAS_INSTALL_DIR
}
/include"
CACHE PATH
"openblas include directory."
FORCE
)
IF
(
WIN32
)
SET
(
CBLAS_LIBRARIES
"
${
CBLAS_INSTALL_DIR
}
/lib/openblas.lib"
CACHE FILEPATH
"openblas library."
FORCE
)
ELSE
(
WIN32
)
SET
(
CBLAS_LIBRARIES
"
${
CBLAS_INSTALL_DIR
}
/lib/libopenblas.a"
CACHE FILEPATH
"openblas library"
FORCE
)
ENDIF
(
WIN32
)
SET
(
CBLAS_LIBRARIES
"
${
CBLAS_INSTALL_DIR
}
/lib/
${
LIBRARY_PREFIX
}
openblas
${
STATIC_LIBRARY_SUFFIX
}
"
CACHE FILEPATH
"openblas library."
FORCE
)
SET
(
COMMON_ARGS CC=
${
CMAKE_C_COMPILER
}
NO_LAPACK=1 NO_SHARED=1
)
IF
(
ANDROID
)
# arm_soft_fp_abi branch of OpenBLAS to support softfp
# https://github.com/xianyi/OpenBLAS/tree/arm_soft_fp_abi
SET
(
OPENBLAS_COMMIT
"b5c96fcfcdc82945502a2303116a64d89985daf5"
)
SET
(
OPTIONAL_ARGS HOSTCC=
${
HOST_C_COMPILER
}
TARGET=ARMV7 ARM_SOFTFP_ABI=1 USE_THREAD=0 libs
)
ELSEIF
(
RPI
)
# use hardfp
SET
(
OPENBLAS_COMMIT
"v0.2.19"
)
SET
(
OPTIONAL_ARGS HOSTCC=
${
HOST_C_COMPILER
}
TARGET=ARMV7 USE_THREAD=0 libs
)
ELSE
()
SET
(
OPENBLAS_COMMIT
"v0.2.19"
)
SET
(
OPENBLAS_ARGS DYNAMIC_ARCH=1 libs
)
ENDIF
()
ExternalProject_Add
(
openblas
${
EXTERNAL_PROJECT_LOG_ARGS
}
GIT_REPOSITORY https://github.com/xianyi/OpenBLAS.git
GIT_TAG
v0.2.19
GIT_TAG
${
OPENBLAS_COMMIT
}
PREFIX
${
CBLAS_SOURCES_DIR
}
INSTALL_DIR
${
CBLAS_INSTALL_DIR
}
BUILD_IN_SOURCE 1
BUILD_COMMAND
${
CMAKE_MAKE_PROGRAM
}
FC=
${
CMAKE_Fortran_COMPILER
}
CC=
${
CMAKE_C_COMPILER
}
HOSTCC=
${
CMAKE_C_COMPILER
}
NO_LAPACK=1 DYNAMIC_ARCH=1 NO_SHARED=1 libs netlib
BUILD_COMMAND
${
CMAKE_MAKE_PROGRAM
}
${
COMMON_ARGS
}
${
OPTIONAL_ARGS
}
INSTALL_COMMAND
${
CMAKE_MAKE_PROGRAM
}
install NO_SHARED=1 PREFIX=<INSTALL_DIR>
UPDATE_COMMAND
""
CONFIGURE_COMMAND
""
)
ExternalProject_Add_Step
(
openblas lapacke_install
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
CBLAS_SOURCES_DIR
}
/src/openblas/lapack-netlib/LAPACKE/include/lapacke_mangling_with_flags.h"
"
${
CBLAS_INSTALL_DIR
}
/include/lapacke_mangling.h"
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
CBLAS_SOURCES_DIR
}
/src/openblas/lapack-netlib/LAPACKE/include/lapacke.h"
"
${
CBLAS_INSTALL_DIR
}
/include/lapacke.h"
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
CBLAS_SOURCES_DIR
}
/src/openblas/lapack-netlib/LAPACKE/include/lapacke_config.h"
"
${
CBLAS_INSTALL_DIR
}
/include/lapacke_config.h"
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
CBLAS_SOURCES_DIR
}
/src/openblas/lapack-netlib/LAPACKE/include/lapacke_utils.h"
"
${
CBLAS_INSTALL_DIR
}
/include/lapacke_utils.h"
DEPENDEES install
IF
(
NOT ANDROID AND NOT RPI
)
ExternalProject_Add_Step
(
openblas lapacke_install
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
CBLAS_SOURCES_DIR
}
/src/openblas/lapack-netlib/LAPACKE/include/lapacke_mangling_with_flags.h"
"
${
CBLAS_INSTALL_DIR
}
/include/lapacke_mangling.h"
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
CBLAS_SOURCES_DIR
}
/src/openblas/lapack-netlib/LAPACKE/include/lapacke.h"
"
${
CBLAS_INSTALL_DIR
}
/include/lapacke.h"
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
CBLAS_SOURCES_DIR
}
/src/openblas/lapack-netlib/LAPACKE/include/lapacke_config.h"
"
${
CBLAS_INSTALL_DIR
}
/include/lapacke_config.h"
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
CBLAS_SOURCES_DIR
}
/src/openblas/lapack-netlib/LAPACKE/include/lapacke_utils.h"
"
${
CBLAS_INSTALL_DIR
}
/include/lapacke_utils.h"
DEPENDEES install
)
ENDIF
()
LIST
(
APPEND external_project_dependencies openblas
)
ENDIF
(
NOT
${
CBLAS_FOUND
}
)
MESSAGE
(
STATUS
"BLAS library:
${
CBLAS_LIBRARIES
}
"
)
INCLUDE_DIRECTORIES
(
${
CBLAS_INC_DIR
}
)
cmake/external/protobuf.cmake
浏览文件 @
47150d4d
...
...
@@ -14,42 +14,42 @@
INCLUDE
(
ExternalProject
)
set
(
PROTOBUF_VERSION 3.1
)
FIND_PACKAGE
(
Protobuf
${
PROTOBUF_VERSION
}
)
FUNCTION
(
build_protobuf TARGET_NAME BUILD_FOR_HOST
)
SET
(
PROTOBUF_SOURCES_DIR
${
THIRD_PARTY_PATH
}
/
${
TARGET_NAME
}
)
SET
(
PROTOBUF_INSTALL_DIR
${
THIRD_PARTY_PATH
}
/install/
${
TARGET_NAME
}
)
IF
(
PROTOBUF_FOUND
)
EXEC_PROGRAM
(
${
PROTOBUF_PROTOC_EXECUTABLE
}
ARGS --version OUTPUT_VARIABLE PROTOBUF_VERSION
)
STRING
(
REGEX MATCH
"[0-9]+.[0-9]+"
PROTOBUF_VERSION
"
${
PROTOBUF_VERSION
}
"
)
IF
(
"
${
PROTOBUF_VERSION
}
"
VERSION_LESS
"3.1.0"
)
SET
(
PROTOBUF_FOUND OFF
)
ENDIF
()
ENDIF
(
PROTOBUF_FOUND
)
IF
(
NOT PROTOBUF_FOUND
)
SET
(
PROTOBUF_SOURCES_DIR
${
THIRD_PARTY_PATH
}
/protobuf
)
SET
(
PROTOBUF_INSTALL_DIR
${
THIRD_PARTY_PATH
}
/install/protobuf
)
SET
(
PROTOBUF_INCLUDE_DIR
"
${
PROTOBUF_INSTALL_DIR
}
/include"
CACHE PATH
"protobuf include directory."
FORCE
)
SET
(
${
TARGET_NAME
}
_INCLUDE_DIR
"
${
PROTOBUF_INSTALL_DIR
}
/include"
PARENT_SCOPE
)
SET
(
PROTOBUF_INCLUDE_DIR
"
${
PROTOBUF_INSTALL_DIR
}
/include"
PARENT_SCOPE
)
SET
(
${
TARGET_NAME
}
_LITE_LIBRARY
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotobuf-lite
${
STATIC_LIBRARY_SUFFIX
}
"
PARENT_SCOPE
)
SET
(
${
TARGET_NAME
}
_LIBRARY
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotobuf
${
STATIC_LIBRARY_SUFFIX
}
"
PARENT_SCOPE
)
SET
(
${
TARGET_NAME
}
_PROTOC_LIBRARY
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotoc
${
STATIC_LIBRARY_SUFFIX
}
"
PARENT_SCOPE
)
SET
(
${
TARGET_NAME
}
_PROTOC_EXECUTABLE
"
${
PROTOBUF_INSTALL_DIR
}
/bin/protoc
${
EXECUTABLE_SUFFIX
}
"
PARENT_SCOPE
)
IF
(
WIN32
)
SET
(
PROTOBUF_LITE_LIBRARY
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotobuf-lite.lib"
CACHE FILEPATH
"protobuf lite library."
FORCE
)
SET
(
PROTOBUF_LIBRARY
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotobuf.lib"
CACHE FILEPATH
"protobuf library."
FORCE
)
SET
(
PROTOBUF_PROTOC_LIBRARY
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotoc.lib"
CACHE FILEPATH
"protoc library."
FORCE
)
SET
(
PROTOBUF_PROTOC_EXECUTABLE
"
${
PROTOBUF_INSTALL_DIR
}
/bin/protoc.exe"
CACHE FILEPATH
"protobuf executable."
FORCE
)
ELSE
(
WIN32
)
SET
(
PROTOBUF_LITE_LIBRARY
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotobuf-lite.a"
CACHE FILEPATH
"protobuf lite library."
FORCE
)
SET
(
PROTOBUF_LIBRARY
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotobuf.a"
CACHE FILEPATH
"protobuf library."
FORCE
)
SET
(
PROTOBUF_PROTOC_LIBRARY
"
${
PROTOBUF_INSTALL_DIR
}
/lib/libprotoc.a"
CACHE FILEPATH
"protoc library."
FORCE
)
SET
(
PROTOBUF_PROTOC_EXECUTABLE
"
${
PROTOBUF_INSTALL_DIR
}
/bin/protoc"
CACHE FILEPATH
"protobuf executable."
FORCE
)
ENDIF
(
WIN32
)
SET
(
OPTIONAL_CACHE_ARGS
""
)
SET
(
OPTIONAL_ARGS
""
)
IF
(
BUILD_FOR_HOST
)
SET
(
OPTIONAL_ARGS
"-Dprotobuf_WITH_ZLIB=OFF"
)
ELSE
()
SET
(
OPTIONAL_ARGS
"-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
"
"-DCMAKE_C_COMPILER=
${
CMAKE_C_COMPILER
}
"
"-DCMAKE_CXX_FLAGS=
${
CMAKE_CXX_FLAGS
}
"
"-DCMAKE_C_FLAGS=
${
CMAKE_C_FLAGS
}
"
"-Dprotobuf_WITH_ZLIB=ON"
"-DZLIB_ROOT:FILEPATH=
${
ZLIB_ROOT
}
"
)
SET
(
OPTIONAL_CACHE_ARGS
"-DZLIB_ROOT:STRING=
${
ZLIB_ROOT
}
"
)
ENDIF
()
ExternalProject_Add
(
protobuf
${
TARGET_NAME
}
${
EXTERNAL_PROJECT_LOG_ARGS
}
PREFIX
${
PROTOBUF_SOURCES_DIR
}
UPDATE_COMMAND
""
...
...
@@ -57,11 +57,9 @@ IF(NOT PROTOBUF_FOUND)
GIT_REPOSITORY
"https://github.com/google/protobuf.git"
GIT_TAG
"9f75c5aa851cd877fb0d93ccc31b8567a6706546"
CONFIGURE_COMMAND
${
CMAKE_COMMAND
}
${
PROTOBUF_SOURCES_DIR
}
/src/protobuf/cmake
${
CMAKE_COMMAND
}
${
PROTOBUF_SOURCES_DIR
}
/src/
${
TARGET_NAME
}
/cmake
${
OPTIONAL_ARGS
}
-Dprotobuf_BUILD_TESTS=OFF
-DZLIB_ROOT:FILEPATH=
${
ZLIB_ROOT
}
-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
-DCMAKE_C_COMPILER=
${
CMAKE_C_COMPILER
}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=
${
PROTOBUF_INSTALL_DIR
}
...
...
@@ -71,10 +69,44 @@ IF(NOT PROTOBUF_FOUND)
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DZLIB_ROOT:STRING=
${
ZLIB_ROOT
}
${
OPTIONAL_CACHE_ARGS
}
)
ENDFUNCTION
()
SET
(
PROTOBUF_VERSION 3.1
)
IF
(
NOT CMAKE_CROSSCOMPILING
)
FIND_PACKAGE
(
Protobuf
${
PROTOBUF_VERSION
}
)
IF
(
PROTOBUF_FOUND
)
EXEC_PROGRAM
(
${
PROTOBUF_PROTOC_EXECUTABLE
}
ARGS --version OUTPUT_VARIABLE PROTOBUF_VERSION
)
STRING
(
REGEX MATCH
"[0-9]+.[0-9]+"
PROTOBUF_VERSION
"
${
PROTOBUF_VERSION
}
"
)
IF
(
"
${
PROTOBUF_VERSION
}
"
VERSION_LESS
"3.1.0"
)
SET
(
PROTOBUF_FOUND OFF
)
ENDIF
()
ENDIF
(
PROTOBUF_FOUND
)
ELSE
()
build_protobuf
(
protobuf_host TRUE
)
LIST
(
APPEND external_project_dependencies protobuf_host
)
SET
(
PROTOBUF_PROTOC_EXECUTABLE
${
protobuf_host_PROTOC_EXECUTABLE
}
CACHE FILEPATH
"protobuf executable."
FORCE
)
ENDIF
()
IF
(
NOT PROTOBUF_FOUND
)
build_protobuf
(
protobuf FALSE
)
LIST
(
APPEND external_project_dependencies protobuf
)
SET
(
PROTOBUF_INCLUDE_DIR
${
protobuf_INCLUDE_DIR
}
CACHE PATH
"protobuf include directory."
FORCE
)
IF
(
NOT CMAKE_CROSSCOMPILING
)
SET
(
PROTOBUF_PROTOC_EXECUTABLE
${
protobuf_PROTOC_EXECUTABLE
}
CACHE FILEPATH
"protobuf executable."
FORCE
)
ENDIF
()
SET
(
PROTOBUF_LITE_LIBRARY
${
protobuf_LITE_LIBRARY
}
CACHE FILEPATH
"protobuf lite library."
FORCE
)
SET
(
PROTOBUF_LIBRARY
${
protobuf_LIBRARY
}
CACHE FILEPATH
"protobuf library."
FORCE
)
SET
(
PROTOBUF_PROTOC_LIBRARY
${
protobuf_PROTOC_LIBRARY
}
CACHE FILEPATH
"protoc library."
FORCE
)
ENDIF
(
NOT PROTOBUF_FOUND
)
MESSAGE
(
STATUS
"Protobuf protoc executable:
${
PROTOBUF_PROTOC_EXECUTABLE
}
"
)
MESSAGE
(
STATUS
"Protobuf library:
${
PROTOBUF_LIBRARY
}
"
)
INCLUDE_DIRECTORIES
(
${
PROTOBUF_INCLUDE_DIR
}
)
cmake/system.cmake
浏览文件 @
47150d4d
...
...
@@ -13,9 +13,9 @@
# limitations under the License.
# Detects the OS and sets appropriate variables.
# CMAKE_SYSTEM_NAME only give us a coarse-grained name
,
# bu
t the name like centos is necessary in some scenes
# to distinguish system for customization.
# CMAKE_SYSTEM_NAME only give us a coarse-grained name
of the OS CMake is
# bu
ilding for, but the host processor name like centos is necessary
#
in some scenes
to distinguish system for customization.
#
# for instance, protobuf libs path is <install_dir>/lib64
# on CentOS, but <install_dir>/lib on other systems.
...
...
@@ -72,12 +72,36 @@ MARK_AS_ADVANCED(HOST_SYSTEM CPU_CORES)
MESSAGE
(
STATUS
"Found Paddle host system:
${
HOST_SYSTEM
}
"
)
MESSAGE
(
STATUS
"Found Paddle host system's CPU:
${
CPU_CORES
}
cores"
)
# configuration for cross-compiling
IF
(
DEFINED CMAKE_SYSTEM_NAME
)
INCLUDE
(
cross_compiling/host
)
IF
(
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"Android"
)
SET
(
ANDROID TRUE
)
INCLUDE
(
cross_compiling/android
)
ELSEIF
(
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"RPi"
)
SET
(
RPI TRUE
)
INCLUDE
(
cross_compiling/raspberry_pi
)
ENDIF
()
ENDIF
()
# prefix and suffix on different os
IF
(
WIN32
)
SET
(
LIBRARY_PREFIX
""
)
SET
(
SHARED_LIBRARY_SUFFIX
".dll"
)
SET
(
STATIC_LIBRARY_SUFFIX
".lib"
)
SET
(
EXECUTABLE_SUFFIX
".exe"
)
ELSE
(
WIN32
)
SET
(
LIBRARY_PREFIX
"lib"
)
IF
(
APPLE
)
SET
(
SHARED_LIBRARY_SUFFIX
".dylib"
)
ELSE
(
APPLE
)
SET
(
SHARED_LIBRARY_SUFFIX
".so"
)
ENDIF
(
APPLE
)
SET
(
STATIC_LIBRARY_SUFFIX
".a"
)
SET
(
EXECUTABLE_SUFFIX
""
)
ENDIF
(
WIN32
)
# external dependencies log output
SET
(
EXTERNAL_PROJECT_LOG_ARGS
LOG_DOWNLOAD 0
# Wrap download in script to log output
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录