1 # Copyright (c) 2018 Stefan Seefeld
3 # Use, modification and distribution is subject to the Boost Software
4 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
5 # http://www.boost.org/LICENSE_1_0.txt)
7 # Supports the opencl library
9 # After 'using opencl', the following targets are available:
11 # /opencl//opencl -- The OpenCL library
17 import "class" : new ;
27 if --debug-configuration in [ modules.peek : ARGV ]
32 # Initializes the opencl library.
34 # Options for configuring opencl::
37 # The directory containing the OpenCL library.
39 # Overrides the default library name.
41 # The directory containing the OpenCL headers.
45 # # Find OpenCL in the default system location
47 # # Find opencl in /usr/local
48 # using opencl : 1.2.7
49 # : <include>/usr/local/include <search>/usr/local/lib ;
51 rule init ( version ? : # The opencl version (currently ignored)
52 options * : # A list of the options to use
53 requirements * ) # The requirements for the opencl target
55 local caller = [ project.current ] ;
61 project.initialize $(__name__) ;
62 .project = [ project.current ] ;
66 local library-path = [ feature.get-values <search> : $(options) ] ;
67 local include-path = [ feature.get-values <include> : $(options) ] ;
68 local library-name = [ feature.get-values <name> : $(options) ] ;
70 if ! $(library-path) && ! $(include-path) && ! $(library-name)
75 condition = [ property-set.create $(requirements) ] ;
76 condition = [ property-set.create [ $(condition).base ] ] ;
78 if $(.configured.$(condition))
84 ECHO "notice: [opencl] opencl is already configured" ;
89 errors.user-error "opencl is already configured" ;
97 ECHO "notice: [opencl] Using pre-installed library" ;
100 ECHO "notice: [opencl] Condition" [ $(condition).raw ] ;
104 local mt = [ new ac-library opencl : $(.project) : $(condition) :
105 $(include-path) : $(library-path) : $(library-name) ] ;
106 $(mt).set-header $(header) ;
107 $(mt).set-default-names $(names) ;
108 targets.main-target-alternative $(mt) ;
110 .configured.$(condition) = true ;