From 871b576c06415abf6faf4d3ac54e11621e487e72 Mon Sep 17 00:00:00 2001 From: CNugteren Date: Tue, 28 Jun 2016 16:38:45 +0200 Subject: Made it possible to build the clients and tests on Windows using Visual Studio --- .appveyor.yml | 2 +- CMakeLists.txt | 41 ++++++++++++++++++++++++++++------------- src/utilities.cpp | 2 +- src/utilities.hpp | 2 +- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index d6540815..08f186ec 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -46,7 +46,7 @@ install: before_build: - ps: mkdir $env:CLBLAST_ROOT - ps: pushd $env:CLBLAST_ROOT - - cmake -G"Visual Studio 14 Win64" -DSAMPLES=ON %APPVEYOR_BUILD_FOLDER% + - cmake -G "Visual Studio 14 Win64" -DTESTS=ON -DCLIENTS=ON -DSAMPLES=ON %APPVEYOR_BUILD_FOLDER% build_script: - cmake --build . diff --git a/CMakeLists.txt b/CMakeLists.txt index fe679285..ad396ddd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,24 +274,31 @@ endif() # library, either clBLAS or a CPU BLAS. if(CLIENTS) - # Creates the common performance-tests objects (requires CMake 2.8.8) - add_library(test_performance_common OBJECT test/performance/client.cpp) + # Visual Studio requires the sources of non-exported objects/libraries + set(CLIENTS_COMMON ) + if(MSVC) + set(CLIENTS_COMMON ${CLIENTS_COMMON} src/utilities.cpp test/performance/client.cpp) + else() + # Creates the common performance-tests objects (requires CMake 2.8.8) + add_library(test_performance_common OBJECT test/performance/client.cpp) + set(CLIENTS_COMMON ${CLIENTS_COMMON} $) + endif() # Compiles the performance-tests foreach(ROUTINE ${LEVEL1_ROUTINES}) - add_executable(clblast_client_${ROUTINE} $ + add_executable(clblast_client_${ROUTINE} ${CLIENTS_COMMON} test/performance/routines/level1/${ROUTINE}.cpp) endforeach() foreach(ROUTINE ${LEVEL2_ROUTINES}) - add_executable(clblast_client_${ROUTINE} $ + add_executable(clblast_client_${ROUTINE} ${CLIENTS_COMMON} test/performance/routines/level2/${ROUTINE}.cpp) endforeach() foreach(ROUTINE ${LEVEL3_ROUTINES}) - add_executable(clblast_client_${ROUTINE} $ + add_executable(clblast_client_${ROUTINE} ${CLIENTS_COMMON} test/performance/routines/level3/${ROUTINE}.cpp) endforeach() foreach(ROUTINE ${LEVELX_ROUTINES}) - add_executable(clblast_client_${ROUTINE} $ + add_executable(clblast_client_${ROUTINE} ${CLIENTS_COMMON} test/performance/routines/levelx/${ROUTINE}.cpp) endforeach() foreach(ROUTINE ${ROUTINES}) @@ -308,25 +315,33 @@ endif() if(TESTS) enable_testing() - # Creates the common correctness-tests objects (requires CMake 2.8.8) - add_library(test_correctness_common OBJECT - test/correctness/tester.cpp test/correctness/testblas.cpp) + # Visual Studio requires the sources of non-exported objects/libraries + set(TESTS_COMMON ) + if(MSVC) + set(TESTS_COMMON ${TESTS_COMMON} src/utilities.cpp + test/correctness/tester.cpp test/correctness/testblas.cpp) + else() + # Creates the common correctness-tests objects (requires CMake 2.8.8) + add_library(test_correctness_common OBJECT + test/correctness/tester.cpp test/correctness/testblas.cpp) + set(TESTS_COMMON ${TESTS_COMMON} $) + endif() # Compiles the correctness-tests foreach(ROUTINE ${LEVEL1_ROUTINES}) - add_executable(clblast_test_${ROUTINE} $ + add_executable(clblast_test_${ROUTINE} ${TESTS_COMMON} test/correctness/routines/level1/${ROUTINE}.cpp) endforeach() foreach(ROUTINE ${LEVEL2_ROUTINES}) - add_executable(clblast_test_${ROUTINE} $ + add_executable(clblast_test_${ROUTINE} ${TESTS_COMMON} test/correctness/routines/level2/${ROUTINE}.cpp) endforeach() foreach(ROUTINE ${LEVEL3_ROUTINES}) - add_executable(clblast_test_${ROUTINE} $ + add_executable(clblast_test_${ROUTINE} ${TESTS_COMMON} test/correctness/routines/level3/${ROUTINE}.cpp) endforeach() foreach(ROUTINE ${LEVELX_ROUTINES}) - add_executable(clblast_test_${ROUTINE} $ + add_executable(clblast_test_${ROUTINE} ${TESTS_COMMON} test/correctness/routines/levelx/${ROUTINE}.cpp) endforeach() foreach(ROUTINE ${ROUTINES}) diff --git a/src/utilities.cpp b/src/utilities.cpp index e3a1fb75..68e480c5 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -182,7 +182,7 @@ template <> double2 ConvertArgument(const char* value) { // This function matches patterns in the form of "-option value" or "--option value". It returns a // default value in case the option is not found in the argument string. template -T GetArgument(const int argc, char *argv[], std::string &help, +T GetArgument(const int argc, char **argv, std::string &help, const std::string &option, const T default_value) { // Parses the argument. Note that this supports both the given option (e.g. -device) and one with diff --git a/src/utilities.hpp b/src/utilities.hpp index 9a2b9ffc..5a4eef0f 100644 --- a/src/utilities.hpp +++ b/src/utilities.hpp @@ -188,7 +188,7 @@ T ConvertArgument(const char* value); // Basic argument parser, matching patterns in the form of "-option value" and "--option value" template -T GetArgument(const int argc, char *argv[], std::string &help, +T GetArgument(const int argc, char **argv, std::string &help, const std::string &option, const T default_value); // Returns the precision only -- cgit v1.2.3