Skip to content

Commit

Permalink
fix: correctly enforce FFTW thread-safety
Browse files Browse the repository at this point in the history
Some preprocessor and cmake mistakes broke this.

This problem was causing crashes. This commit might resolve #85
  • Loading branch information
hello-adam committed Mar 16, 2021
1 parent 505acae commit 586042a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
@@ -1,3 +1,3 @@
[submodule "src/cmake/findFFTW"]
[submodule "cmake/findFFTW"]
path = cmake/findFFTW
url = https://github.com/egpbos/findFFTW
url = https://github.com/hello-adam/findFFTW
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -68,7 +68,7 @@ endif()
find_package(Qt5Core CONFIG REQUIRED)
find_package(Qt5Widgets CONFIG REQUIRED)
find_package(Qt5Network CONFIG REQUIRED)
find_package(FFTW)
find_package(FFTW COMPONENTS DOUBLE_LIB DOUBLE_THREADS_LIB)
if (NOT WIN32)
find_package(PCAP REQUIRED)
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/findFFTW
Submodule findFFTW updated 2 files
+296 −216 FindFFTW.cmake
+6 −0 README.md
9 changes: 8 additions & 1 deletion src/hobbits-gui/CMakeLists.txt
Expand Up @@ -16,7 +16,14 @@ file(GLOB_RECURSE HDRFILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SO
file(GLOB RCFILES "${CMAKE_CURRENT_SOURCE_DIR}/*.qrc" "${CMAKE_CURRENT_SOURCE_DIR}/*.ui")

add_executable("hobbits" MACOSX_BUNDLE "${SRCFILES}" "${HDRFILES}" "${RCFILES}")
target_link_libraries("hobbits" hobbits-python hobbits-widgets hobbits-core Qt5::Widgets)
set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core Qt5::Widgets)
if (FFTW_FOUND)
add_definitions(-DFFTW_AVAILABLE)

list(APPEND ALL_LINK_LIBS FFTW::Double FFTW::DoubleThreads)
target_include_directories("hobbits" PRIVATE "${FFTW_INCLUDE_DIRS}")
endif()
target_link_libraries("hobbits" ${ALL_LINK_LIBS})
#harden("hobbits")

if (APPLE)
Expand Down
8 changes: 7 additions & 1 deletion src/hobbits-runner/CMakeLists.txt
Expand Up @@ -15,7 +15,13 @@ file(GLOB_RECURSE HDRFILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SO
file(GLOB RCFILES "${CMAKE_CURRENT_SOURCE_DIR}/*.qrc" "${CMAKE_CURRENT_SOURCE_DIR}/*.ui")

add_executable("hobbits-runner" "${SRCFILES}" "${HDRFILES}" "${RCFILES}")
target_link_libraries("hobbits-runner" hobbits-python hobbits-widgets hobbits-core Qt5::Widgets)
set(ALL_LINK_LIBS hobbits-python hobbits-widgets hobbits-core Qt5::Widgets)
if (FFTW_FOUND)
add_definitions(-DFFTW_AVAILABLE)
list(APPEND ALL_LINK_LIBS FFTW::Double FFTW::DoubleThreads)
target_include_directories("hobbits-runner" PRIVATE "${FFTW_INCLUDE_DIRS}")
endif()
target_link_libraries("hobbits-runner" ${ALL_LINK_LIBS})
#harden("hobbits-runner")

if (APPLE)
Expand Down
9 changes: 9 additions & 0 deletions src/hobbits-runner/main.cpp
Expand Up @@ -18,8 +18,17 @@
#include "hobbitspythonconfig.h"
#include "pythonpluginconfig.h"

#ifdef FFTW_AVAILABLE
#include "fftw3.h"
#endif

int main(int argc, char *argv[])
{
#ifdef FFTW_AVAILABLE
// See http://www.fftw.org/fftw3_doc/Thread-safety.html
fftw_make_planner_thread_safe();
#endif

QGuiApplication a(argc, argv);

QGuiApplication::setApplicationName("Hobbits Runner");
Expand Down

0 comments on commit 586042a

Please sign in to comment.