Skip to content

Commit 03981bb

Browse files
committed
Disable long double builds in MSVC with preprocessor
1 parent 9a78483 commit 03981bb

5 files changed

Lines changed: 24 additions & 9 deletions

File tree

.appveyor.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ environment:
4545
FFTW_INSTALL_MODE: official
4646
FFTW_ROOT: C:\fftw_download
4747

48-
# TODO: conda-forge build doen, CMakeLists aanpassen zodat FFTW_LONGDOUBLE niet required is bij CMAKE_CXX_COMPILER_ID == MSVC
49-
# sowieso is libs requiren beetje raar als je alleen installeert;
50-
# mss beter om als ze niet gevonden zijn de test/bench builds uit te zetten
5148
# TODO: goed idee (?): een MSVC_FFTW_LONGDOUBLE_LINKING_WORKAROUND option toevoegen die manually een long double lib downloadt zodat de tests iig linken, maar met een melding dat die dus niet goed draaien
5249

5350
matrix:
@@ -117,9 +114,7 @@ install:
117114
- nmake test_xtensor-fftw
118115

119116
before_build:
120-
# - copy C:\fftw_download\*.* test
121117
- cd test
122118

123119
build_script:
124-
# The long double FFTW library only works when sizeof(long double) == 12. In recent VC versions, long double is an alias of double, and so long double will not work with fftw3l. The long double tests are usually third in the list, so index 2 starting from 0, e.g. "TransformAndInvert/2".
125-
- test_xtensor-fftw.exe --gtest_filter=-*/2*
120+
- test_xtensor-fftw.exe

CMakeLists.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,35 @@ endif()
5858
set(CMAKE_CXX_STANDARD 14)
5959
set(CMAKE_CXX_STANDARD_REQUIRED YES)
6060
set(CMAKE_CXX_EXTENSIONS NO)
61+
6162
# includes
63+
6264
# .. our own
6365
include_directories(${XTENSOR_FFTW_INCLUDE_DIR})
66+
6467
# .. xtensor
6568
find_package(xtensor REQUIRED)
6669
message(STATUS "Found xtensor: ${xtensor_INCLUDE_DIRS}/xtensor")
6770
include_directories(${xtensor_INCLUDE_DIRS})
71+
6872
# .. xtl
6973
find_package(xtl REQUIRED)
7074
message(STATUS "Found xtl: ${xtl_INCLUDE_DIRS}/xtl")
7175
include_directories(${xtl_INCLUDE_DIRS})
76+
7277
# .. fftw
73-
find_package(FFTW REQUIRED
74-
COMPONENTS FLOAT_LIB DOUBLE_LIB LONGDOUBLE_LIB)
78+
if(MSVC)
79+
# no long double component, since in the Windows conda-forge build it is not available
80+
# and the "official" prebuilt long double library can only be used from MinGW
81+
find_package(FFTW REQUIRED
82+
COMPONENTS FLOAT_LIB DOUBLE_LIB)
83+
add_definitions(-DFFTW_NO_LONGDOUBLE)
84+
else()
85+
find_package(FFTW REQUIRED
86+
COMPONENTS FLOAT_LIB DOUBLE_LIB LONGDOUBLE_LIB)
87+
endif(MSVC)
7588
include_directories(${FFTW_INCLUDE_DIRS})
89+
7690
# warnings (gcc and clang)
7791
if (COMPILE_WARNINGS)
7892
add_compile_options(-Wundef -Wshadow -Wwrite-strings -Wredundant-decls -Woverloaded-virtual -Wcast-qual -Wcast-align -Wpointer-arith -Wconversion -Wold-style-cast -Wall -Wextra)

bench/basic_interface.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ BENCHMARK_F(rfft2Dxarray_float, TransformAndInvert_nD)(::benchmark::State& st) {
129129
// }
130130
//}
131131
//
132+
//#ifndef FFTW_NO_LONGDOUBLE
132133
//BENCHMARK_TEMPLATE_F(rfft1Dxarray, TransformAndInvert, long double)(::benchmark::State& st) {
133134
// for (auto _ : st) {
134135
// auto a_fourier = xt::fftw::rfft(a);
@@ -137,6 +138,7 @@ BENCHMARK_F(rfft2Dxarray_float, TransformAndInvert_nD)(::benchmark::State& st) {
137138
// ::benchmark::DoNotOptimize(should_be_a);
138139
// }
139140
//}
141+
//#endif // FFTW_NO_LONGDOUBLE
140142

141143

142144
BENCHMARK_MAIN()

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ add_executable(${XTENSOR_FFTW_TARGET} ${XTENSOR_FFTW_TESTS} ${XTENSOR_HEADERS} $
104104
if(DOWNLOAD_GTEST OR GTEST_SRC_DIR)
105105
add_dependencies(${XTENSOR_FFTW_TARGET} gtest_main)
106106
endif()
107-
target_link_libraries(${XTENSOR_FFTW_TARGET} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${FFTW_FLOAT_LIB} ${FFTW_DOUBLE_LIB} ${FFTW_LONGDOUBLE_LIB})
107+
target_link_libraries(${XTENSOR_FFTW_TARGET} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${FFTW_LIBRARIES})
108108

109109
add_custom_target(xtest COMMAND test_xtensor-fftw DEPENDS ${XTENSOR_FFTW_TARGET})
110110

test/basic_interface.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ template <typename T>
3030
class TransformAndInvert : public ::testing::Test {};
3131

3232
// the GoogleTest list of typed test cases
33+
#ifdef FFTW_NO_LONGDOUBLE
34+
typedef ::testing::Types<float, double> MyTypes;
35+
#else
3336
typedef ::testing::Types<float, double, long double> MyTypes;
37+
#endif // FFTW_NO_LONGDOUBLE
3438
TYPED_TEST_CASE(TransformAndInvert, MyTypes);
3539

3640
// Generates a dim-dimensional array of size n in each dimension, filled with random numbers between 0 and the numeric

0 commit comments

Comments
 (0)