Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 47 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,39 +36,51 @@ find_package(MKL)
find_package(glbinding QUIET)
include(boost_package)

option(BUILD_CPU "Build ArrayFire with a CPU backend" ON)
option(BUILD_CUDA "Build ArrayFire with a CUDA backend" ${CUDA_FOUND})
option(BUILD_OPENCL "Build ArrayFire with a OpenCL backend" ${OpenCL_FOUND})
option(BUILD_UNIFIED "Build Backend-Independent ArrayFire API" ON)
option(AF_BUILD_CPU "Build ArrayFire with a CPU backend" ON)
option(AF_BUILD_CUDA "Build ArrayFire with a CUDA backend" ${CUDA_FOUND})
option(AF_BUILD_OPENCL "Build ArrayFire with a OpenCL backend" ${OpenCL_FOUND})
option(AF_BUILD_UNIFIED "Build Backend-Independent ArrayFire API" ON)
option(AF_BUILD_DOCS "Create ArrayFire Documentation" ${DOXYGEN_FOUND})
option(AF_BUILD_EXAMPLES "Build Examples" ON)

option(BUILD_GRAPHICS "Build ArrayFire with Forge Graphics" $<AND:${OPENGL_FOUND},${Forge_FOUND},${glbinding_FOUND}>)
option(BUILD_DOCS "Create ArrayFire Documentation" ${DOXYGEN_FOUND})
option(BUILD_NONFREE "Build ArrayFire nonfree algorithms" OFF)
option(AF_WITH_GRAPHICS "Build ArrayFire with Forge Graphics" $<AND:${OPENGL_FOUND},${Forge_FOUND},${glbinding_FOUND}>)
option(AF_WITH_NONFREE "Build ArrayFire nonfree algorithms" OFF)

option(BUILD_EXAMPLES "Build Examples" ON)
cmake_dependent_option(USE_RELATIVE_TEST_DIR "Use relative paths for the test data directory(For continious integration(CI) purposes only)" OFF
cmake_dependent_option(AF_WITH_RELATIVE_TEST_DIR "Use relative paths for the test data directory(For continious integration(CI) purposes only)" OFF
"BUILD_TESTING" OFF)

cmake_dependent_option(USE_SYSTEM_FORGE "Use system Forge" OFF
"BUILD_GRAPHICS" OFF)
cmake_dependent_option(WITH_IMAGEIO "Build ArrayFire with Image IO support" ${FreeImage_FOUND}
"FreeImage_FOUND" OFF)
cmake_dependent_option(BUILD_FRAMEWORK "Build an ArrayFire framework for Apple platforms.(Experimental)" OFF
"APPLE" OFF)
option(USE_FREEIMAGE_STATIC "Use Static FreeImage Lib" OFF)

set(USE_CPUID ON CACHE BOOL "Build with CPUID integration")
cmake_dependent_option(AF_USE_SYSTEM_FORGE "Use system Forge" OFF
"AF_WITH_GRAPHICS" OFF)
cmake_dependent_option(AF_WITH_IMAGEIO "Build ArrayFire with Image IO support" ${FreeImage_FOUND}
"FreeImage_FOUND" OFF)
cmake_dependent_option(AF_BUILD_FRAMEWORK "Build an ArrayFire framework for Apple platforms.(Experimental)" OFF
"APPLE" OFF)
option(AF_WITH_STATIC_FREEIMAGE "Use Static FreeImage Lib" OFF)

set(AF_WITH_CPUID ON CACHE BOOL "Build with CPUID integration")

af_deprecate(BUILD_CPU AF_BUILD_CPU)
af_deprecate(BUILD_CUDA AF_BUILD_CUDA)
af_deprecate(BUILD_OPENCL AF_BUILD_OPENCL)
af_deprecate(BUILD_UNIFIED AF_BUILD_UNIFIED)
af_deprecate(BUILD_GRAPHICS AF_WITH_GRAPHICS)
af_deprecate(BUILD_DOCS AF_BUILD_DOCS)
af_deprecate(BUILD_NONFREE AF_WITH_NONFREE)
af_deprecate(BUILD_EXAMPLES AF_WITH_EXAMPLES)
af_deprecate(USE_RELATIVE_TEST_DIR AF_WITH_RELATIVE_TEST_DIR)
af_deprecate(USE_FREEIMAGE_STATIC AF_WITH_STATIC_FREEIMAGE)
af_deprecate(USE_CPUID AF_WITH_CPUID)

mark_as_advanced(
BUILD_FRAMEWORK
USE_SYSTEM_FORGE
USE_CPUID)
AF_BUILD_FRAMEWORK
AF_USE_SYSTEM_FORGE
AF_WITH_CPUID)

# TODO(umar): Add definitions should not be used. Instead use
arrayfire_get_platform_definitions(platform_definitions)
add_definitions(${platform_definitions})

if(BUILD_GRAPHICS)
if(AF_WITH_GRAPHICS)
include(build_forge)
endif()

Expand All @@ -77,7 +89,7 @@ configure_file(
${ArrayFire_BINARY_DIR}/version.hpp
)

if(BUILD_NONFREE)
if(AF_WITH_NONFREE)
message("Building with NONFREE requires the following patents")
message("Method and apparatus for identifying scale invariant features\n"
"in an image and use of same for locating an object in an image, David\n"
Expand Down Expand Up @@ -105,10 +117,10 @@ add_subdirectory(src/backend/common)
add_subdirectory(src/api/c)
add_subdirectory(src/api/cpp)

conditional_directory(BUILD_CPU src/backend/cpu)
conditional_directory(BUILD_CUDA src/backend/cuda)
conditional_directory(BUILD_OPENCL src/backend/opencl)
conditional_directory(BUILD_UNIFIED src/api/unified)
conditional_directory(AF_BUILD_CPU src/backend/cpu)
conditional_directory(AF_BUILD_CUDA src/backend/cuda)
conditional_directory(AF_BUILD_OPENCL src/backend/opencl)
conditional_directory(AF_BUILD_UNIFIED src/api/unified)

if(TARGET af)
list(APPEND built_backends af)
Expand All @@ -134,7 +146,7 @@ foreach(backend ${built_backends})
target_compile_definitions(${backend} PRIVATE AFDLL)
endforeach()

if(BUILD_FRAMEWORK)
if(AF_BUILD_FRAMEWORK)
set_target_properties(${built_backends}
PROPERTIES
FRAMEWORK TRUE
Expand All @@ -161,7 +173,7 @@ install(FILES
COMPONENT headers
)

if(Forge_FOUND AND NOT USE_SYSTEM_FORGE)
if(Forge_FOUND AND NOT AF_USE_SYSTEM_FORGE)
option(INSTALL_FORGE_DEV "Install Forge Header and Share Files with ArrayFire" OFF)
install(DIRECTORY "${ArrayFire_BINARY_DIR}/third_party/forge/lib/"
DESTINATION "${AF_INSTALL_LIB_DIR}"
Expand All @@ -179,10 +191,10 @@ if(Forge_FOUND AND NOT USE_SYSTEM_FORGE)
endif()
endif()

# install the examples irrespective of the BUILD_EXAMPLES value
# install the examples irrespective of the AF_BUILD_EXAMPLES value
# only the examples source files are installed, so the installation of these
# source files does not depend on BUILD_EXAMPLES
# when BUILD_EXAMPLES is OFF, the examples source is installed without
# source files does not depend on AF_BUILD_EXAMPLES
# when AF_BUILD_EXAMPLES is OFF, the examples source is installed without
# building the example executables
install(DIRECTORY examples/ #NOTE The slash at the end is important
DESTINATION ${AF_INSTALL_EXAMPLE_DIR}
Expand All @@ -194,7 +206,7 @@ install(DIRECTORY assets/examples/ #NOTE The slash at the end is important

foreach(backend CPU CUDA OpenCL Unified)
string(TOUPPER ${backend} upper_backend)
if(BUILD_${upper_backend})
if(AF_BUILD_${upper_backend})
install(EXPORT ArrayFire${backend}Targets
NAMESPACE ArrayFire::
DESTINATION ${AF_INSTALL_CMAKE_DIR}
Expand Down Expand Up @@ -278,5 +290,5 @@ endif()
conditional_directory(BUILD_TESTING test)

set(ASSETS_DIR "${ArrayFire_SOURCE_DIR}/assets")
conditional_directory(BUILD_EXAMPLES examples)
conditional_directory(BUILD_DOCS docs)
conditional_directory(AF_BUILD_EXAMPLES examples)
conditional_directory(AF_BUILD_DOCS docs)
2 changes: 1 addition & 1 deletion CMakeModules/CPackConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set(CPACK_PACKAGE_VERSION ${ArrayFire_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR "${ArrayFire_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${ArrayFire_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${ArrayFire_VERSION_PATCH}")
if(BUILD_GRAPHICS)
if(AF_WITH_GRAPHICS)
set(CPACK_PACKAGE_FILE_NAME
${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION})
else()
Expand Down
16 changes: 16 additions & 0 deletions CMakeModules/InternalUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ function(arrayfire_get_cuda_cxx_flags cuda_flags)
endif()
endfunction()

function(__af_deprecate_var var access value)
if(access STREQUAL "READ_ACCESS")
message(DEPRECATION "Variable ${var} is deprecated. Use AF_${var} instead.")
endif()
endfunction()

function(af_deprecate var newvar)
if(DEFINED ${var})
message(DEPRECATION "Variable ${var} is deprecated. Use ${newvar} instead.")
get_property(doc CACHE ${newvar} PROPERTY HELPSTRING)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this doc defined ? Is it predefined ? I didn't find any reference to it in root cmake script or here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its the variable where the get_property command stores the HELPSTRING for the ${newvar} variable.

set(${newvar} ${${var}} CACHE BOOL "${doc}" FORCE)
unset(${var} CACHE)
endif()
variable_watch(${var} __af_deprecate_var)
endfunction()

macro(arrayfire_set_cmake_default_variables)
set(CMAKE_PREFIX_PATH "${ArrayFire_BINARY_DIR}/cmake;${CMAKE_PREFIX_PATH}")
set(BUILD_SHARED_LIBS ON)
Expand Down
26 changes: 13 additions & 13 deletions CMakeModules/osx_install/OSXInstaller.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ ADD_CUSTOM_TARGET(OSX_INSTALL_SETUP_DOC
COMMENT "Copying documentation files to temporary OSX Install Dir"
)

IF(BUILD_GRAPHICS)
IF(AF_WITH_GRAPHICS)
MAKE_DIRECTORY("${OSX_TEMP}/Forge")

# Forge library versions for setting up symlinks
Expand Down Expand Up @@ -157,7 +157,7 @@ IF(BUILD_GRAPHICS)
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Copying documentation files to temporary OSX Install Dir"
)
ENDIF(BUILD_GRAPHICS)
ENDIF(AF_WITH_GRAPHICS)
################################################################################

FUNCTION(PKG_BUILD)
Expand Down Expand Up @@ -190,11 +190,11 @@ ENDFUNCTION(PKG_BUILD)

FUNCTION(PRODUCT_BUILD)
CMAKE_PARSE_ARGUMENTS(ARGS "" "" "DEPENDS" ${ARGN})
IF(BUILD_GRAPHICS)
IF(AF_WITH_GRAPHICS)
SET(DISTRIBUTION_FILE "${OSX_INSTALL_SOURCE}/distribution.dist")
ELSE(BUILD_GRAPHICS)
ELSE(AF_WITH_GRAPHICS)
SET(DISTRIBUTION_FILE "${OSX_INSTALL_SOURCE}/distribution-no-gl.dist")
ENDIF(BUILD_GRAPHICS)
ENDIF(AF_WITH_GRAPHICS)

SET(DISTRIBUTION_FILE_OUT "${CMAKE_CURRENT_BINARY_DIR}/distribution.dist.out")

Expand All @@ -209,11 +209,11 @@ FUNCTION(PRODUCT_BUILD)
CONFIGURE_FILE(${WELCOME_FILE} ${WELCOME_FILE_OUT})
CONFIGURE_FILE(${README_FILE} ${README_FILE_OUT})

IF(BUILD_GRAPHICS)
IF(AF_WITH_GRAPHICS)
SET(PACKAGE_NAME "arrayfire-${AF_VERSION}.pkg")
ELSE(BUILD_GRAPHICS)
ELSE(AF_WITH_GRAPHICS)
SET(PACKAGE_NAME "arrayfire-no-gl-${AF_VERSION}.pkg")
ENDIF(BUILD_GRAPHICS)
ENDIF(AF_WITH_GRAPHICS)

ADD_CUSTOM_COMMAND( OUTPUT ${PACKAGE_NAME}
DEPENDS ${ARGS_DEPENDS}
Expand Down Expand Up @@ -289,7 +289,7 @@ PKG_BUILD( PKG_NAME ArrayFireDoc
PATH_TO_FILES ${OSX_TEMP}/doc
FILTERS cmake)

IF(BUILD_GRAPHICS)
IF(AF_WITH_GRAPHICS)
PKG_BUILD( PKG_NAME ForgeLibrary
DEPENDS OSX_INSTALL_SETUP_FORGE_LIB
TARGETS forge_lib_package
Expand Down Expand Up @@ -328,16 +328,16 @@ IF(BUILD_GRAPHICS)
IDENTIFIER com.arrayfire.pkg.forge.cmake
PATH_TO_FILES ${OSX_TEMP}/Forge/cmake
)
ENDIF(BUILD_GRAPHICS)
ENDIF(AF_WITH_GRAPHICS)

IF(BUILD_GRAPHICS)
IF(AF_WITH_GRAPHICS)
PRODUCT_BUILD(DEPENDS ${cpu_package} ${cuda_package} ${opencl_package} ${unified_package}
${common_package} ${header_package} ${examples_package} ${doc_package}
${forge_lib_package} ${forge_header_package} ${forge_examples_package} ${forge_doc_package} ${forge_cmake_package}
)
ELSE(BUILD_GRAPHICS)
ELSE(AF_WITH_GRAPHICS)
PRODUCT_BUILD(DEPENDS ${cpu_package} ${cuda_package} ${opencl_package} ${unified_package}
${common_package} ${header_package} ${examples_package} ${doc_package}
)
ENDIF(BUILD_GRAPHICS)
ENDIF(AF_WITH_GRAPHICS)

4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ process; however, the compiled examples are not packaged in the ArrayFire
installer. After compiling ArrayFire, the examples will be in subdirectories
located in the `build/examples` directory.

If you wish to disable example compilation, simply set the `BUILD_EXAMPLES`
If you wish to disable example compilation, simply set the `AF_BUILD_EXAMPLES`
variable to `OFF` in the CMake GUI or `ccmake` curses wrapper. If you are
using the command-line version of `cmake`, simply specify
`-DBUILD_EXAMPLES=OFF` as an argument.
`-DAF_BUILD_EXAMPLES=OFF` as an argument.

## Building examples as a stand-alone project

Expand Down
4 changes: 2 additions & 2 deletions src/api/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ target_sources(c_api_interface
${CMAKE_CURRENT_SOURCE_DIR}/ycbcr_rgb.cpp
)

if(FreeImage_FOUND AND WITH_IMAGEIO)
if(FreeImage_FOUND AND AF_WITH_IMAGEIO)
target_compile_definitions(c_api_interface INTERFACE WITH_FREEIMAGE)
target_link_libraries( c_api_interface INTERFACE FreeImage::FreeImage)
endif()

if(BUILD_GRAPHICS)
if(AF_WITH_GRAPHICS)
add_dependencies(c_api_interface forge-ext)
target_compile_definitions(c_api_interface INTERFACE WITH_GRAPHICS)
endif()
Expand Down
4 changes: 2 additions & 2 deletions src/api/c/sift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ af_err af_sift(af_features* feat, af_array* desc, const af_array in, const unsig
const bool double_input, const float img_scale, const float feature_ratio)
{
try {
#ifdef AF_BUILD_NONFREE_SIFT
#ifdef AF_WITH_NONFREE_SIFT
const ArrayInfo& info = getInfo(in);
af::dim4 dims = info.dims();

Expand Down Expand Up @@ -95,7 +95,7 @@ af_err af_gloh(af_features* feat, af_array* desc, const af_array in, const unsig
const bool double_input, const float img_scale, const float feature_ratio)
{
try {
#ifdef AF_BUILD_NONFREE_SIFT
#ifdef AF_WITH_NONFREE_SIFT
const ArrayInfo& info = getInfo(in);
af::dim4 dims = info.dims();

Expand Down
2 changes: 1 addition & 1 deletion src/backend/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ target_include_directories(afcommon_interface

add_library(afcommon_lapack_interface INTERFACE)

if(BUILD_GRAPHICS)
if(AF_WITH_GRAPHICS)
dependency_check(glbinding_FOUND "glbinding not found.")

target_include_directories(afcommon_interface
Expand Down
12 changes: 6 additions & 6 deletions src/backend/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ target_sources(afcpu
kernel/wrap.hpp
)

if (USE_CPUID)
target_compile_definitions(afcpu PRIVATE -DUSE_CPUID)
endif(USE_CPUID)
if (AF_WITH_CPUID)
target_compile_definitions(afcpu PRIVATE -DAF_WITH_CPUID)
endif(AF_WITH_CPUID)

target_sources(afcpu
PRIVATE
Expand All @@ -258,12 +258,12 @@ endif()

include("${CMAKE_CURRENT_SOURCE_DIR}/kernel/sort_by_key/CMakeLists.txt")

if(BUILD_NONFREE)
if(AF_WITH_NONFREE)
target_sources(afcpu PRIVATE kernel/sift_nonfree.hpp)
target_compile_definitions(afcpu PRIVATE AF_BUILD_NONFREE_SIFT)
target_compile_definitions(afcpu PRIVATE AF_WITH_NONFREE_SIFT)
endif()

if(BUILD_GRAPHICS)
if(AF_WITH_GRAPHICS)
add_dependencies(afcpu forge-ext)
target_sources(afcpu
PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion src/backend/cpu/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <memory.hpp>
#include <queue.hpp>

#if defined(USE_CPUID) && (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) || defined(_WIN64))
#if defined(AF_WITH_CPUID) && (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) || defined(_WIN64))
#define CPUID_CAPABLE
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/backend/cpu/sift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <cfloat>
#include <vector>

#ifdef AF_BUILD_NONFREE_SIFT
#ifdef AF_WITH_NONFREE_SIFT
#include <kernel/sift_nonfree.hpp>
#endif

Expand All @@ -37,7 +37,7 @@ unsigned sift(Array<float>& x, Array<float>& y, Array<float>& score,
const float img_scale, const float feature_ratio,
const bool compute_GLOH)
{
#ifdef AF_BUILD_NONFREE_SIFT
#ifdef AF_WITH_NONFREE_SIFT
return sift_impl<T, convAccT>(x, y, score, ori, size, desc, in, n_layers,
contrast_thr, edge_thr, init_sigma, double_input,
img_scale, feature_ratio, compute_GLOH);
Expand Down
10 changes: 5 additions & 5 deletions src/backend/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ if(NOT MSVC)
set(cuda_cxx_flags "${cuda_cxx_flags} -Xcompiler -fPIC")
endif()

if(BUILD_NONFREE AND CMAKE_VERSION VERSION_LESS "3.7")
if(AF_WITH_NONFREE AND CMAKE_VERSION VERSION_LESS "3.7")
# This definition is required in addition to the definition below because in
# an older verion of cmake definitions added using target_compile_definitions
# were not added to the nvcc flags. This manually adds these definitions and
# pass them to the options parameter in cuda_add_library
string(APPEND cuda_cxx_flags " -DAF_BUILD_NONFREE_SIFT")
string(APPEND cuda_cxx_flags " -DAF_WITH_NONFREE_SIFT")
endif()

include(kernel/scan_by_key/CMakeLists.txt)
Expand Down Expand Up @@ -409,11 +409,11 @@ cuda_add_library(afcuda

add_library(ArrayFire::afcuda ALIAS afcuda)

if(BUILD_NONFREE)
target_compile_definitions(afcuda PRIVATE AF_BUILD_NONFREE_SIFT)
if(AF_WITH_NONFREE)
target_compile_definitions(afcuda PRIVATE AF_WITH_NONFREE_SIFT)
endif()

if(BUILD_GRAPHICS)
if(AF_WITH_GRAPHICS)
target_sources(afcuda
PRIVATE
GraphicsResourceManager.cpp
Expand Down
Loading