From b58546d6654cb4feb7104462221d9d60a73112e6 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Mon, 5 Oct 2020 23:32:17 +0200
Subject: [PATCH] ctd

---
 Core/CMakeLists.txt           | 25 -------------------------
 Fit/CMakeLists.txt            | 25 -------------------------
 cmake/BornAgain/SwigLib.cmake | 23 +++++++++++++++++++++++
 3 files changed, 23 insertions(+), 50 deletions(-)

diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt
index 19262458906..e6f5abbbadc 100644
--- a/Core/CMakeLists.txt
+++ b/Core/CMakeLists.txt
@@ -29,31 +29,6 @@ set(${lib}_LIBRARY_TYPE SHARED)
 
 if(BORNAGAIN_PYTHON)
     SwigLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap)
-
-    add_custom_target(
-        ${lib}_python
-        COMMAND ${CMAKE_COMMAND}
-            -E copy ${AUTO_DIR}/lib${lib}.py ${CMAKE_BINARY_DIR}/lib/lib${lib}.py
-        COMMAND ${CMAKE_COMMAND}
-            -E copy ${AUTO_DIR}/lib${lib}.py ${CMAKE_BINARY_DIR}/lib/bornagain/lib${lib}.py
-        DEPENDS ${AUTO_DIR}/lib${lib}.py
-        )
-
-    if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
-            OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
-        # suppress warnings from auto-generated code (last updated for Swig 4.0.1)
-        set_source_files_properties(${AUTO_DIR}/lib${lib}_wrap.cpp
-            PROPERTIES COMPILE_OPTIONS
-            "-Wno-unused-parameter;-Wno-missing-field-initializers;-Wno-sometimes-uninitialized;\
--Wno-deprecated-declarations")
-    endif()
-
-    add_dependencies(${lib} ${lib}_python)
-
-    target_compile_definitions(${lib} PUBLIC -DBORNAGAIN_PYTHON)
-    target_include_directories(${lib} PUBLIC ${Python3_INCLUDE_DIRS} ${Python3_NumPy_INCLUDE_DIRS})
-    target_link_libraries(${lib} ${Python3_LIBRARIES})
-
 endif(BORNAGAIN_PYTHON)
 
 # exposing library name and list of include directories outside
diff --git a/Fit/CMakeLists.txt b/Fit/CMakeLists.txt
index 1e53df4f271..c4d423cdad0 100644
--- a/Fit/CMakeLists.txt
+++ b/Fit/CMakeLists.txt
@@ -22,31 +22,6 @@ set(${lib}_LIBRARY_TYPE SHARED)
 
 if(BORNAGAIN_PYTHON)
     SwigLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap)
-
-    add_custom_target(
-        ${lib}_python
-        COMMAND ${CMAKE_COMMAND}
-            -E copy ${AUTO_DIR}/lib${lib}.py ${CMAKE_BINARY_DIR}/lib/lib${lib}.py
-        COMMAND ${CMAKE_COMMAND}
-            -E copy ${AUTO_DIR}/lib${lib}.py ${CMAKE_BINARY_DIR}/lib/bornagain/lib${lib}.py
-        DEPENDS ${AUTO_DIR}/lib${lib}.py
-        )
-
-    if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
-            OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
-        # suppress warnings from auto-generated code (last updated for Swig 4.0.1)
-        set_source_files_properties(${AUTO_DIR}/lib${lib}_wrap.cpp
-            PROPERTIES COMPILE_OPTIONS
-            "-Wno-unused-parameter;-Wno-missing-field-initializers;-Wno-sometimes-uninitialized;\
--Wno-deprecated-declarations")
-    endif()
-
-    add_dependencies(${lib} ${lib}_python)
-
-    target_compile_definitions(${lib} PUBLIC -DBORNAGAIN_PYTHON)
-    target_include_directories(${lib} PUBLIC ${Python3_INCLUDE_DIRS} ${Python3_NumPy_INCLUDE_DIRS})
-    target_link_libraries(${lib} ${Python3_LIBRARIES})
-
 endif(BORNAGAIN_PYTHON)
 
 # exposing library name and list of include directories outside
diff --git a/cmake/BornAgain/SwigLib.cmake b/cmake/BornAgain/SwigLib.cmake
index dce997bc0f1..2ccb8a738ae 100644
--- a/cmake/BornAgain/SwigLib.cmake
+++ b/cmake/BornAgain/SwigLib.cmake
@@ -45,5 +45,28 @@ function(SwigLib name lib TMP_DIR)
 
     endif(CONFIGURE_BINDINGS)
 
+    add_custom_target(
+        ${lib}_python
+        COMMAND ${CMAKE_COMMAND}
+            -E copy ${AUTO_DIR}/lib${lib}.py ${CMAKE_BINARY_DIR}/lib/lib${lib}.py
+        COMMAND ${CMAKE_COMMAND}
+            -E copy ${AUTO_DIR}/lib${lib}.py ${CMAKE_BINARY_DIR}/lib/bornagain/lib${lib}.py
+        DEPENDS ${AUTO_DIR}/lib${lib}.py
+        )
+
+    if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+            OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
+        # suppress warnings from auto-generated code (last updated for Swig 4.0.1)
+        set_source_files_properties(${AUTO_DIR}/lib${lib}_wrap.cpp
+            PROPERTIES COMPILE_OPTIONS
+            "-Wno-unused-parameter;-Wno-missing-field-initializers;-Wno-sometimes-uninitialized;\
+-Wno-deprecated-declarations")
+    endif()
+
+    add_dependencies(${lib} ${lib}_python)
+
+    target_compile_definitions(${lib} PUBLIC -DBORNAGAIN_PYTHON)
+    target_include_directories(${lib} PUBLIC ${Python3_INCLUDE_DIRS} ${Python3_NumPy_INCLUDE_DIRS})
+    target_link_libraries(${lib} ${Python3_LIBRARIES})
 
 endfunction()
-- 
GitLab