| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # ######################################################################## | ||
| # Copyright 2013 Advanced Micro Devices, Inc. | ||
| # | ||
| # 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. | ||
| # ######################################################################## | ||
|
|
||
| INCLUDE_DIRECTORIES( | ||
| "${CMAKE_CURRENT_SOURCE_DIR}" | ||
| "${OPENCL_INCLUDE_DIRS}" | ||
| "${PROJECT_SOURCE_DIR}/include" | ||
| "${PROJECT_BINARY_DIR}/include" | ||
| ) | ||
|
|
||
| LINK_DIRECTORIES("${PROJECT_BINARY_DIR}/package/lib${SUFFIX_LIB}") | ||
|
|
||
| FILE(GLOB FILES "*.c") | ||
|
|
||
| FOREACH(FILE ${FILES}) | ||
|
|
||
| if( MSVC ) | ||
| if( MSVC_VERSION LESS 1800 ) | ||
| # Use C++ with Microsoft compiler | ||
| SET_SOURCE_FILES_PROPERTIES( ${FILE} PROPERTIES LANGUAGE CXX) | ||
| endif () | ||
| endif( ) | ||
|
|
||
| GET_FILENAME_COMPONENT(EXAMPLE ${FILE} NAME_WE) | ||
| GET_FILENAME_COMPONENT(FULL_DIR_NAME ${FILE} PATH) | ||
| GET_FILENAME_COMPONENT(DIR_NAME ${FULL_DIR_NAME} NAME) | ||
| SET(EXAMPLE_NAME example_${DIR_NAME}_${EXAMPLE}) | ||
| ADD_EXECUTABLE(${EXAMPLE_NAME} ${FILE}) | ||
|
|
||
| TARGET_LINK_LIBRARIES(${EXAMPLE_NAME} clFFT ${OPENCL_LIBRARIES}) | ||
|
|
||
| SET_TARGET_PROPERTIES(${EXAMPLE_NAME} | ||
| PROPERTIES | ||
| OUTPUT_NAME ${EXAMPLE} | ||
| RUNTIME_OUTPUT_DIRECTORY ${DIR_NAME}) | ||
|
|
||
| INSTALL(TARGETS ${EXAMPLE_NAME} | ||
| RUNTIME DESTINATION "bin${SUFFIX_BIN}/examples") | ||
| ENDFOREACH() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| /* ************************************************************************ | ||
| * Copyright 2013 Advanced Micro Devices, Inc. | ||
| * | ||
| * 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. | ||
| * ************************************************************************/ | ||
|
|
||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
|
|
||
| /* No need to explicitely include the OpenCL headers */ | ||
| #include <clFFT.h> | ||
|
|
||
| int main( void ) | ||
| { | ||
| cl_int err; | ||
| cl_platform_id platform = 0; | ||
| cl_device_id device = 0; | ||
| cl_context_properties props[3] = { CL_CONTEXT_PLATFORM, 0, 0 }; | ||
| cl_context ctx = 0; | ||
| cl_command_queue queue = 0; | ||
| cl_mem bufX; | ||
| float *X; | ||
| cl_event event = NULL; | ||
| int ret = 0; | ||
| size_t N = 16; | ||
| char platform_name[128]; | ||
| char device_name[128]; | ||
|
|
||
| /* FFT library realted declarations */ | ||
| clfftPlanHandle planHandle; | ||
| clfftDim dim = CLFFT_1D; | ||
| size_t clLengths[1] = {N}; | ||
|
|
||
| /* Setup OpenCL environment. */ | ||
| err = clGetPlatformIDs( 1, &platform, NULL ); | ||
|
|
||
| size_t ret_param_size = 0; | ||
| err = clGetPlatformInfo(platform, CL_PLATFORM_NAME, | ||
| sizeof(platform_name), platform_name, | ||
| &ret_param_size); | ||
| printf("Platform found: %s\n", platform_name); | ||
|
|
||
| err = clGetDeviceIDs( platform, CL_DEVICE_TYPE_DEFAULT, 1, &device, NULL ); | ||
|
|
||
| err = clGetDeviceInfo(device, CL_DEVICE_NAME, | ||
| sizeof(device_name), device_name, | ||
| &ret_param_size); | ||
| printf("Device found on the above platform: %s\n", device_name); | ||
|
|
||
| props[1] = (cl_context_properties)platform; | ||
| ctx = clCreateContext( props, 1, &device, NULL, NULL, &err ); | ||
| queue = clCreateCommandQueue( ctx, device, 0, &err ); | ||
|
|
||
| /* Setup clFFT. */ | ||
| clfftSetupData fftSetup; | ||
| err = clfftInitSetupData(&fftSetup); | ||
| err = clfftSetup(&fftSetup); | ||
|
|
||
| /* Allocate host & initialize data. */ | ||
| /* Only allocation shown for simplicity. */ | ||
| X = (float *)malloc(N * 2 * sizeof(*X)); | ||
|
|
||
| /* print input array */ | ||
| printf("\nPerforming fft on an one dimensional array of size N = %ld\n", N); | ||
| int print_iter = 0; | ||
| while(print_iter<N) { | ||
| float x = print_iter; | ||
| float y = print_iter*3; | ||
| X[2*print_iter ] = x; | ||
| X[2*print_iter+1] = y; | ||
| printf("(%f, %f) ", x, y); | ||
| print_iter++; | ||
| } | ||
| printf("\n\nfft result: \n"); | ||
|
|
||
| /* Prepare OpenCL memory objects and place data inside them. */ | ||
| bufX = clCreateBuffer( ctx, CL_MEM_READ_WRITE, N * 2 * sizeof(*X), NULL, &err ); | ||
|
|
||
| err = clEnqueueWriteBuffer( queue, bufX, CL_TRUE, 0, | ||
| N * 2 * sizeof( *X ), X, 0, NULL, NULL ); | ||
|
|
||
| /* Create a default plan for a complex FFT. */ | ||
| err = clfftCreateDefaultPlan(&planHandle, ctx, dim, clLengths); | ||
|
|
||
| /* Set plan parameters. */ | ||
| err = clfftSetPlanPrecision(planHandle, CLFFT_SINGLE); | ||
| err = clfftSetLayout(planHandle, CLFFT_COMPLEX_INTERLEAVED, CLFFT_COMPLEX_INTERLEAVED); | ||
| err = clfftSetResultLocation(planHandle, CLFFT_INPLACE); | ||
|
|
||
| /* Bake the plan. */ | ||
| err = clfftBakePlan(planHandle, 1, &queue, NULL, NULL); | ||
|
|
||
| /* Execute the plan. */ | ||
| err = clfftEnqueueTransform(planHandle, CLFFT_FORWARD, 1, &queue, 0, NULL, NULL, &bufX, NULL, NULL); | ||
|
|
||
| /* Wait for calculations to be finished. */ | ||
| err = clFinish(queue); | ||
|
|
||
| /* Fetch results of calculations. */ | ||
| err = clEnqueueReadBuffer( queue, bufX, CL_TRUE, 0, N * 2 * sizeof( *X ), X, 0, NULL, NULL ); | ||
|
|
||
| /* print output array */ | ||
| print_iter = 0; | ||
| while(print_iter<N) { | ||
| printf("(%f, %f) ", X[2*print_iter], X[2*print_iter+1]); | ||
| print_iter++; | ||
| } | ||
| printf("\n"); | ||
|
|
||
| /* Release OpenCL memory objects. */ | ||
| clReleaseMemObject( bufX ); | ||
|
|
||
| free(X); | ||
|
|
||
| /* Release the plan. */ | ||
| err = clfftDestroyPlan( &planHandle ); | ||
|
|
||
| /* Release clFFT library. */ | ||
| clfftTeardown( ); | ||
|
|
||
| /* Release OpenCL working objects. */ | ||
| clReleaseCommandQueue( queue ); | ||
| clReleaseContext( ctx ); | ||
|
|
||
| return ret; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| /* ************************************************************************ | ||
| * Copyright 2013 Advanced Micro Devices, Inc. | ||
| * | ||
| * 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. | ||
| * ************************************************************************/ | ||
|
|
||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
|
|
||
| /* No need to explicitely include the OpenCL headers */ | ||
| #include <clFFT.h> | ||
|
|
||
| int main( void ) | ||
| { | ||
| cl_int err; | ||
| cl_platform_id platform = 0; | ||
| cl_device_id device = 0; | ||
| cl_context_properties props[3] = { CL_CONTEXT_PLATFORM, 0, 0 }; | ||
| cl_context ctx = 0; | ||
| cl_command_queue queue = 0; | ||
| cl_mem bufX; | ||
| float *X; | ||
| cl_event event = NULL; | ||
| int ret = 0; | ||
|
|
||
| const size_t N0 = 8, N1 = 8; | ||
| char platform_name[128]; | ||
| char device_name[128]; | ||
|
|
||
| /* FFT library realted declarations */ | ||
| clfftPlanHandle planHandle; | ||
| clfftDim dim = CLFFT_2D; | ||
| size_t clLengths[2] = {N0, N1}; | ||
|
|
||
| /* Setup OpenCL environment. */ | ||
| err = clGetPlatformIDs( 1, &platform, NULL ); | ||
|
|
||
| size_t ret_param_size = 0; | ||
| err = clGetPlatformInfo(platform, CL_PLATFORM_NAME, | ||
| sizeof(platform_name), platform_name, | ||
| &ret_param_size); | ||
| printf("Platform found: %s\n", platform_name); | ||
|
|
||
| err = clGetDeviceIDs( platform, CL_DEVICE_TYPE_DEFAULT, 1, &device, NULL ); | ||
|
|
||
| err = clGetDeviceInfo(device, CL_DEVICE_NAME, | ||
| sizeof(device_name), device_name, | ||
| &ret_param_size); | ||
| printf("Device found on the above platform: %s\n", device_name); | ||
|
|
||
| props[1] = (cl_context_properties)platform; | ||
| ctx = clCreateContext( props, 1, &device, NULL, NULL, &err ); | ||
| queue = clCreateCommandQueue( ctx, device, 0, &err ); | ||
|
|
||
| /* Setup clFFT. */ | ||
| clfftSetupData fftSetup; | ||
| err = clfftInitSetupData(&fftSetup); | ||
| err = clfftSetup(&fftSetup); | ||
|
|
||
| /* Allocate host & initialize data. */ | ||
| /* Only allocation shown for simplicity. */ | ||
| size_t buffer_size = N0 * N1 * 2 * sizeof(*X); | ||
| X = (float *)malloc(buffer_size); | ||
|
|
||
| /* print input array just using the | ||
| * indices to fill the array with data */ | ||
| printf("\nPerforming fft on an two dimensional array of size N0 x N1 : %ld x %ld\n", N0, N1); | ||
| int i, j; | ||
| i = j = 0; | ||
| for (i=0; i<N0; ++i) { | ||
| for (j=0; j<N1; ++j) { | ||
| float x = 0.5f; | ||
| float y = 0.5f; | ||
| unsigned idx = 2*(j+i*N0); | ||
| X[idx] = x; | ||
| X[idx+1] = y; | ||
| printf("(%f, %f) ", x, y); | ||
| } | ||
| printf("\n"); | ||
| } | ||
|
|
||
| /* Prepare OpenCL memory objects and place data inside them. */ | ||
| bufX = clCreateBuffer( ctx, CL_MEM_READ_WRITE, buffer_size, NULL, &err ); | ||
|
|
||
| err = clEnqueueWriteBuffer( queue, bufX, CL_TRUE, 0, buffer_size, X, 0, NULL, NULL ); | ||
|
|
||
| /* Create a default plan for a complex FFT. */ | ||
| err = clfftCreateDefaultPlan(&planHandle, ctx, dim, clLengths); | ||
|
|
||
| /* Set plan parameters. */ | ||
| err = clfftSetPlanPrecision(planHandle, CLFFT_SINGLE); | ||
| err = clfftSetLayout(planHandle, CLFFT_COMPLEX_INTERLEAVED, CLFFT_COMPLEX_INTERLEAVED); | ||
| err = clfftSetResultLocation(planHandle, CLFFT_INPLACE); | ||
|
|
||
| /* Bake the plan. */ | ||
| err = clfftBakePlan(planHandle, 1, &queue, NULL, NULL); | ||
|
|
||
| /* Execute the plan. */ | ||
| err = clfftEnqueueTransform(planHandle, CLFFT_FORWARD, 1, &queue, 0, NULL, NULL, &bufX, NULL, NULL); | ||
|
|
||
| /* Wait for calculations to be finished. */ | ||
| err = clFinish(queue); | ||
|
|
||
| /* Fetch results of calculations. */ | ||
| err = clEnqueueReadBuffer( queue, bufX, CL_TRUE, 0, buffer_size, X, 0, NULL, NULL ); | ||
|
|
||
| /* print output array */ | ||
| printf("\n\nfft result: \n"); | ||
| i = j = 0; | ||
| for (i=0; i<N0; ++i) { | ||
| for (j=0; j<N1; ++j) { | ||
| unsigned idx = 2*(j+i*N0); | ||
| printf("(%f, %f) ", X[idx], X[idx+1]); | ||
| } | ||
| printf("\n"); | ||
| } | ||
| printf("\n"); | ||
|
|
||
| /* Release OpenCL memory objects. */ | ||
| clReleaseMemObject( bufX ); | ||
|
|
||
| free(X); | ||
|
|
||
| /* Release the plan. */ | ||
| err = clfftDestroyPlan( &planHandle ); | ||
|
|
||
| /* Release clFFT library. */ | ||
| clfftTeardown( ); | ||
|
|
||
| /* Release OpenCL working objects. */ | ||
| clReleaseCommandQueue( queue ); | ||
| clReleaseContext( ctx ); | ||
|
|
||
| return ret; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| /* ************************************************************************ | ||
| * Copyright 2013 Advanced Micro Devices, Inc. | ||
| * | ||
| * 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. | ||
| * ************************************************************************/ | ||
|
|
||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
|
|
||
| /* No need to explicitely include the OpenCL headers */ | ||
| #include <clFFT.h> | ||
|
|
||
| int main( void ) | ||
| { | ||
| cl_int err; | ||
| cl_platform_id platform = 0; | ||
| cl_device_id device = 0; | ||
| cl_context_properties props[3] = { CL_CONTEXT_PLATFORM, 0, 0 }; | ||
| cl_context ctx = 0; | ||
| cl_command_queue queue = 0; | ||
| cl_mem bufX; | ||
| float *X; | ||
| cl_event event = NULL; | ||
| int ret = 0; | ||
|
|
||
| const size_t N0 = 4, N1 = 4, N2 = 4; | ||
| char platform_name[128]; | ||
| char device_name[128]; | ||
|
|
||
| /* FFT library realted declarations */ | ||
| clfftPlanHandle planHandle; | ||
| clfftDim dim = CLFFT_3D; | ||
| size_t clLengths[3] = {N0, N1, N2}; | ||
|
|
||
| /* Setup OpenCL environment. */ | ||
| err = clGetPlatformIDs( 1, &platform, NULL ); | ||
|
|
||
| size_t ret_param_size = 0; | ||
| err = clGetPlatformInfo(platform, CL_PLATFORM_NAME, | ||
| sizeof(platform_name), platform_name, | ||
| &ret_param_size); | ||
| printf("Platform found: %s\n", platform_name); | ||
|
|
||
| err = clGetDeviceIDs( platform, CL_DEVICE_TYPE_DEFAULT, 1, &device, NULL ); | ||
|
|
||
| err = clGetDeviceInfo(device, CL_DEVICE_NAME, | ||
| sizeof(device_name), device_name, | ||
| &ret_param_size); | ||
| printf("Device found on the above platform: %s\n", device_name); | ||
|
|
||
| props[1] = (cl_context_properties)platform; | ||
| ctx = clCreateContext( props, 1, &device, NULL, NULL, &err ); | ||
| queue = clCreateCommandQueue( ctx, device, 0, &err ); | ||
|
|
||
| /* Setup clFFT. */ | ||
| clfftSetupData fftSetup; | ||
| err = clfftInitSetupData(&fftSetup); | ||
| err = clfftSetup(&fftSetup); | ||
|
|
||
| /* Allocate host & initialize data. */ | ||
| /* Only allocation shown for simplicity. */ | ||
| size_t buffer_size = N0 * N1 * N2 * 2 * sizeof(*X); | ||
| X = (float *)malloc(buffer_size); | ||
|
|
||
| /* print input array just using the | ||
| * indices to fill the array with data */ | ||
| printf("\nPerforming fft on an two dimensional array of size N0 x N1 x N2 : %ld x %ld x %ld\n", N0, N1, N2); | ||
| int i, j, k; | ||
| i = j = k = 0; | ||
| for (i=0; i<N0; ++i) { | ||
| for (j=0; j<N1; ++j) { | ||
| for (k=0; k<N2; ++k) { | ||
| float x = 0.0f; | ||
| float y = 0.0f; | ||
| if (i==0 && j==0 && k==0) { | ||
| x = y = 0.5f; | ||
| } | ||
| unsigned idx = 2*(k+j*N1+i*N0*N1); | ||
| X[idx] = x; | ||
| X[idx+1] = y; | ||
| printf("(%f, %f) ", X[idx], X[idx+1]); | ||
| } | ||
| printf("\n"); | ||
| } | ||
| printf("\n"); | ||
| } | ||
|
|
||
| /* Prepare OpenCL memory objects and place data inside them. */ | ||
| bufX = clCreateBuffer( ctx, CL_MEM_READ_WRITE, buffer_size, NULL, &err ); | ||
|
|
||
| err = clEnqueueWriteBuffer( queue, bufX, CL_TRUE, 0, buffer_size, X, 0, NULL, NULL ); | ||
|
|
||
| /* Create a default plan for a complex FFT. */ | ||
| err = clfftCreateDefaultPlan(&planHandle, ctx, dim, clLengths); | ||
|
|
||
| /* Set plan parameters. */ | ||
| err = clfftSetPlanPrecision(planHandle, CLFFT_SINGLE); | ||
| err = clfftSetLayout(planHandle, CLFFT_COMPLEX_INTERLEAVED, CLFFT_COMPLEX_INTERLEAVED); | ||
| err = clfftSetResultLocation(planHandle, CLFFT_INPLACE); | ||
|
|
||
| /* Bake the plan. */ | ||
| err = clfftBakePlan(planHandle, 1, &queue, NULL, NULL); | ||
|
|
||
| /* Execute the plan. */ | ||
| err = clfftEnqueueTransform(planHandle, CLFFT_FORWARD, 1, &queue, 0, NULL, NULL, &bufX, NULL, NULL); | ||
|
|
||
| /* Wait for calculations to be finished. */ | ||
| err = clFinish(queue); | ||
|
|
||
| /* Fetch results of calculations. */ | ||
| err = clEnqueueReadBuffer( queue, bufX, CL_TRUE, 0, buffer_size, X, 0, NULL, NULL ); | ||
|
|
||
| /* print output array */ | ||
| printf("\n\nfft result: \n"); | ||
| i = j = k = 0; | ||
| for (i=0; i<N0; ++i) { | ||
| for (j=0; j<N1; ++j) { | ||
| for (k=0; k<N2; ++k) { | ||
| unsigned idx = 2*(k+j*N1+i*N0*N1); | ||
| printf("(%f, %f) ", X[idx], X[idx+1]); | ||
| } | ||
| printf("\n"); | ||
| } | ||
| printf("\n"); | ||
| } | ||
| printf("\n"); | ||
|
|
||
| /* Release OpenCL memory objects. */ | ||
| clReleaseMemObject( bufX ); | ||
|
|
||
| free(X); | ||
|
|
||
| /* Release the plan. */ | ||
| err = clfftDestroyPlan( &planHandle ); | ||
|
|
||
| /* Release clFFT library. */ | ||
| clfftTeardown( ); | ||
|
|
||
| /* Release OpenCL working objects. */ | ||
| clReleaseCommandQueue( queue ); | ||
| clReleaseContext( ctx ); | ||
|
|
||
| return ret; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
|
|
||
| option(USE_SYSTEM_GTEST "Use system installed gtest when set to ON, or build gtest locally when set to OFF" OFF) | ||
|
|
||
| if(USE_SYSTEM_GTEST) | ||
| if( (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 2.8) ) | ||
| message( STATUS "Cmake version 2.8 or greater needed to use GTest" ) | ||
| else() | ||
| # This will define GTEST_FOUND | ||
| find_package( GTest ) | ||
| endif() | ||
| else() | ||
| if(CMAKE_VERSION VERSION_LESS 3.2 AND CMAKE_GENERATOR MATCHES "Ninja") | ||
| message(WARNING "Building GTest with Ninja has known issues with CMake older than 3.2") | ||
| endif() | ||
|
|
||
| include(ExternalProject) | ||
|
|
||
| set(GTEST_LIBRARIES gtest gtest_main) | ||
| # the binary dir must be know before creating the external project in order | ||
| # to pass the byproducts | ||
| set(prefix "${CMAKE_CURRENT_BINARY_DIR}/gtest-external-prefix") | ||
| set(binary_dir "${prefix}/src/gtest-external-build") | ||
|
|
||
| set(byproducts) | ||
| foreach(lib ${GTEST_LIBRARIES}) | ||
| set(${lib}_location | ||
| ${binary_dir}/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
| list(APPEND byproducts ${${lib}_location}) | ||
| endforeach() | ||
|
|
||
| if( MSVC ) | ||
| if( MSVC_VERSION LESS 1800 ) | ||
| set(EXTRA_FLAG "/D_VARIADIC_MAX=10 ") | ||
| else() | ||
| set(EXTRA_FLAG "") | ||
| endif() | ||
| else() | ||
| set(EXTRA_FLAG "") | ||
| endif() | ||
|
|
||
| ExternalProject_Add( | ||
| gtest-external | ||
| URL http://googletest.googlecode.com/files/gtest-1.7.0.zip | ||
| URL_MD5 2d6ec8ccdf5c46b05ba54a9fd1d130d7 | ||
| PREFIX ${prefix} | ||
| BINARY_DIR ${binary_dir} | ||
| CMAKE_CACHE_ARGS | ||
| -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} | ||
| -DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} | ||
| -DCMAKE_CXX_FLAGS_DEBUG:STRING=${EXTRA_FLAG}${CMAKE_CXX_FLAGS_DEBUG} | ||
| -DCMAKE_CXX_FLAGS_MINSIZEREL:STRING=${EXTRA_FLAG}${CMAKE_CXX_FLAGS_MINSIZEREL} | ||
| -DCMAKE_CXX_FLAGS_RELEASE:STRING=${EXTRA_FLAG}${CMAKE_CXX_FLAGS_RELEASE} | ||
| -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=${EXTRA_FLAG}${CMAKE_CXX_FLAGS_RELWITHDEBINFO} | ||
| -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} | ||
| -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} | ||
| -DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG} | ||
| -DCMAKE_C_FLAGS_MINSIZEREL:STRING=${CMAKE_C_FLAGS_MINSIZEREL} | ||
| -DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE} | ||
| -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_C_FLAGS_RELWITHDEBINFO} | ||
| -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} | ||
| -Dgtest_force_shared_crt:BOOL=ON | ||
| BUILD_BYPRODUCTS ${byproducts} | ||
| INSTALL_COMMAND "") | ||
|
|
||
| foreach(lib ${GTEST_LIBRARIES}) | ||
| add_library(${lib} IMPORTED STATIC) | ||
| add_dependencies(${lib} gtest-external) | ||
| set_target_properties(${lib} PROPERTIES IMPORTED_LOCATION ${${lib}_location}) | ||
| endforeach() | ||
|
|
||
| ExternalProject_Get_Property(gtest-external source_dir) | ||
| set(GTEST_INCLUDE_DIRS ${source_dir}/include) | ||
| set(GTEST_FOUND ON) | ||
| endif() | ||
|
|
||
| # Hack to get googletest v1.6 to work with vs2012 | ||
| if( MSVC11 ) | ||
| add_definitions( "/D_VARIADIC_MAX=10" ) | ||
| endif( ) |