Skip to content

Commit

Permalink
cmake3
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Jul 16, 2024
1 parent 3b94fc8 commit 8f58b1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 1 addition & 3 deletions lib/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ macro (ot_check_test TESTNAME)
set (TEST_TARGET t_${TESTNAME})
add_executable (${TEST_TARGET} EXCLUDE_FROM_ALL ${TEST_TARGET}.cxx)
add_dependencies(tests ${TEST_TARGET})
target_include_directories (${TEST_TARGET} PRIVATE ${INTERNAL_INCLUDE_DIRS})
target_link_libraries (${TEST_TARGET} PRIVATE ottemplate)
if (MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_libraries (${TEST_TARGET} PRIVATE CRT_fp8)
Expand Down Expand Up @@ -37,9 +38,6 @@ macro (ot_check_test TESTNAME)
list (APPEND CHECK_TO_BE_RUN ${TEST_TARGET})
endmacro ()

include_directories ( ${INTERNAL_INCLUDE_DIRS} )



ot_check_test (MyClass_std IGNOREOUT)

Expand Down
16 changes: 8 additions & 8 deletions python/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

include_directories (${OPENTURNS_INCLUDE_DIRS})
include_directories (${OPENTURNS_SWIG_INCLUDE_DIRS})
add_definitions (${OPENTURNS_SWIG_DEFINITIONS})
include_directories (${INTERNAL_INCLUDE_DIRS})

# allows one to pass compile flags like -O1 to reduce memory usage
set (SWIG_COMPILE_FLAGS "" CACHE STRING "C++ compiler flags used for wrapper code")

macro (ot_add_python_module MODULENAME SOURCEFILE)
set_source_files_properties (${SOURCEFILE} PROPERTIES CPLUSPLUS ON)
set_source_files_properties (${SOURCEFILE} PROPERTIES SWIG_MODULE_NAME ${MODULENAME})
set_source_files_properties (${SOURCEFILE} PROPERTIES INCLUDE_DIRECTORIES "${INTERNAL_INCLUDE_DIRS};${OPENTURNS_INCLUDE_DIRS};${OPENTURNS_SWIG_INCLUDE_DIRS}")

ot_install_swig_file (${SOURCEFILE})
if (${ARGC} GREATER 2)
set (SWIG_MODULE_${MODULENAME}_python_EXTRA_DEPS ${ARGN})
Expand Down Expand Up @@ -46,18 +45,19 @@ macro (ot_add_python_module MODULENAME SOURCEFILE)
DEPENDS ${docstring_sources})
list (APPEND SWIG_MODULE_${MODULENAME}_python_EXTRA_DEPS generate_${MODULENAME}_docstrings)

# swig_add_module is deprecated
swig_add_library (${MODULENAME}_python LANGUAGE python SOURCES ${SOURCEFILE} ${swig_other_sources})
set (module_target ${MODULENAME}_python)

swig_add_library (${module_target} LANGUAGE python SOURCES ${SOURCEFILE} ${swig_other_sources})

# UseSWIG generates now standard target names
set (module_target ${MODULENAME}_python)

swig_link_libraries (${MODULENAME}_python ottemplate)
target_include_directories (${MODULENAME}_python PRIVATE ${Python_INCLUDE_DIRS})
target_include_directories(${module_target} PRIVATE ${INTERNAL_INCLUDE_DIRS})
swig_link_libraries (${module_target} ottemplate)

if (TARGET Python::Module)
target_link_libraries (${module_target} Python::Module)
else ()
target_include_directories (${module_target} PRIVATE ${Python_INCLUDE_DIRS})
target_link_libraries_with_dynamic_lookup (${module_target} ${Python_LIBRARIES})
endif ()

Expand Down

0 comments on commit 8f58b1d

Please sign in to comment.