Procházet zdrojové kódy

Added CMakeLists.txt

Ovidio Peña Rodríguez před 4 roky
rodič
revize
7184f49ae9
4 změnil soubory, kde provedl 120 přidání a 3 odebrání
  1. 1 2
      .gitignore
  2. 79 0
      CMakeLists.txt
  3. 1 1
      examples/coating-flow.sh
  4. 39 0
      src/CMakeLists.txt

+ 1 - 2
.gitignore

@@ -32,8 +32,7 @@
 
 # CLion files
 .idea
-cmake-build-debug
-CMakeLists.txt
+cmake-build-*
 
 # Temp
 *~

+ 79 - 0
CMakeLists.txt

@@ -0,0 +1,79 @@
+cmake_minimum_required(VERSION 3.15)
+project(scattnlay VERSION 2.3)
+
+cmake_host_system_information(RESULT HOSTNAME QUERY HOSTNAME)
+
+message("Build type is: " ${CMAKE_BUILD_TYPE})
+message("Host OS System: ${CMAKE_HOST_SYSTEM}")
+message("Hostname:  ${HOSTNAME}")
+
+# Select flags.
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g ")
+set(CMAKE_CXX_FLAGS_RELEASE "-O3")
+set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+
+set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+
+add_compile_options(-Wall)
+add_compile_options(-funroll-loops -fstrict-aliasing)
+
+# Set options
+option(ENABLE_MP "Use multiple precision" ON)
+if (${ENABLE_MP})
+    add_compile_options(-DMULTI_PRECISION=100)
+endif ()
+
+# compiler details
+message("  C++ Compiler: ${CMAKE_CXX_COMPILER_ID} "
+        "${CMAKE_CXX_COMPILER_VERSION} "
+        "${CMAKE_CXX_COMPILER_WRAPPER}")
+
+# installation details
+message("  Installation prefix: ${CMAKE_INSTALL_PREFIX}")
+
+# Find Boost
+set(BOOSTROOT $ENV{BOOST_DIR})
+if (USE_STATIC_LIBRARIES)
+    set(Boost_USE_STATIC_LIBS ON)
+endif ()
+set(Boost_USE_MULTITHREADED OFF)
+set(Boost_USE_STATIC_RUNTIME OFF)
+find_package(Boost
+        REQUIRED COMPONENTS chrono filesystem iostreams regex serialization system timer)
+if (Boost_INCLUDE_DIRS)
+    if (${Boost_VERSION} VERSION_LESS 1.60.0)
+        message(FATAL_ERROR
+                "Found Boost library is too old; required is version 1.60.0 or newer!")
+    endif ()
+    message("Found Boost include dir: ${Boost_INCLUDE_DIR}")
+    message("Found Boost library dir: ${Boost_LIBRARY_DIR}")
+    message("Found Boost libraries: ${Boost_LIBRARIES}")
+    include_directories(${Boost_INCLUDE_DIRS})
+endif ()
+
+#Find Python and NumPy
+find_package(Python COMPONENTS Interpreter Development)
+
+include_directories(${Python_INCLUDE_DIRS})
+
+message("Python_EXECUTABLE:${Python_EXECUTABLE}")
+message("Python_FOUND:${Python_FOUND}")
+message("Python_VERSION:${Python_VERSION}")
+message("Python_Development_FOUND:${Python_Development_FOUND}")
+message("Python_LIBRARIES:${Python_LIBRARIES}")
+
+# This comes to hand if we also need to use the NumPy C API
+exec_program(${Python_EXECUTABLE}
+        ARGS "-c \"import numpy; print(numpy.get_include())\""
+        OUTPUT_VARIABLE NUMPY_INCLUDE_DIR
+        RETURN_VALUE NUMPY_NOT_FOUND
+        )
+if (NUMPY_NOT_FOUND)
+    message(FATAL_ERROR "NumPy headers not found")
+endif ()
+
+#include_directories(src)
+add_subdirectory(src)

+ 1 - 1
examples/coating-flow.sh

@@ -5,4 +5,4 @@
 #python coating-flow.py -w 3.75 -t 0.62 -f index-sv.dat -n 1501
 # python coating-flow.py -w 3.75 -t 2.40 -f index-ch.dat -n 501
 
-python coating-flow.py -w 0.532 -t 0.128 -f index-in-glass.dat -n 151
+python3 coating-flow.py -w 0.532 -t 0.128 -f index-in-glass.dat -n 151

+ 39 - 0
src/CMakeLists.txt

@@ -0,0 +1,39 @@
+set(_scattnlay_python_sources
+        ${CMAKE_CURRENT_LIST_DIR}/nmie.hpp
+        ${CMAKE_CURRENT_LIST_DIR}/nmie.cc
+        ${CMAKE_CURRENT_LIST_DIR}/nmie-pybind11.hpp
+        ${CMAKE_CURRENT_LIST_DIR}/nmie-pybind11.cc
+        ${CMAKE_CURRENT_LIST_DIR}/nmie-precision.hpp
+        ${CMAKE_CURRENT_LIST_DIR}/nmie-impl.cc
+        ${CMAKE_CURRENT_LIST_DIR}/pb11_wrapper.cc)
+
+add_library(python3-scattnlay SHARED ${_scattnlay_python_sources})
+target_link_libraries(python3-scattnlay ${PYTHON_LIBRARIES})
+
+set_target_properties(
+        python3-scattnlay
+        PROPERTIES
+        PREFIX ""
+        OUTPUT_NAME "python3-scattnlay"
+        LINKER_LANGUAGE C
+)
+
+add_executable(farfield
+        ${CMAKE_CURRENT_LIST_DIR}/farfield.cc
+        ${CMAKE_CURRENT_LIST_DIR}/nmie.hpp
+        ${CMAKE_CURRENT_LIST_DIR}/nmie.cc)
+
+add_executable(nearfield
+        ${CMAKE_CURRENT_LIST_DIR}/nearfield.cc
+        ${CMAKE_CURRENT_LIST_DIR}/nmie.hpp
+        ${CMAKE_CURRENT_LIST_DIR}/nmie.cc)
+
+if (${ENABLE_MP})
+    set_property(TARGET python3-scattnlay APPEND_STRING PROPERTY OUTPUT_NAME "_mp")
+    set_property(TARGET farfield APPEND_STRING PROPERTY OUTPUT_NAME "farfield-mp")
+    set_property(TARGET nearfield APPEND_STRING PROPERTY OUTPUT_NAME "nearfield-mp")
+else ()
+    set_property(TARGET python3-scattnlay APPEND_STRING PROPERTY OUTPUT_NAME "_sp")
+    set_property(TARGET farfield APPEND_STRING PROPERTY OUTPUT_NAME "farfield-sp")
+    set_property(TARGET nearfield APPEND_STRING PROPERTY OUTPUT_NAME "nearfield-sp")
+endif ()