Skip to content

Commit

Permalink
CMake: Add SWIG_COMPILE_FLAGS
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Oct 25, 2024
1 parent a957d1a commit f24a492
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
pip install mkdocs python-markdown-math --user
PATH=$PATH:~/.local/bin mkdocs build
mkdir build && pushd build
cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_FORTRAN=ON -DCMAKE_C_FLAGS='-std=c89 -pedantic -D_POSIX_C_SOURCE=200809L -Wall -Wextra' -DCMAKE_CXX_FLAGS='-Wall -Wextra' ..
cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_FORTRAN=ON -DCMAKE_C_FLAGS='-std=c89 -pedantic -D_POSIX_C_SOURCE=200809L -Wall -Wextra' -DCMAKE_CXX_FLAGS='-Wall -Wextra' -DSWIG_COMPILE_FLAGS="-Wno-unused-parameter -Wno-missing-field-initializers" ..
make install -j2 && ctest -j2 --output-on-failure
rm -rf * ~/.local
cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_FORTRAN=ON -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake ..
Expand Down
5 changes: 5 additions & 0 deletions src/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ if (POLICY CMP0078)
endif ()
include (UseSWIG)

# allows one set C++ flags for swig wrappers
set (SWIG_COMPILE_FLAGS "" CACHE STRING "C++ compiler flags used for wrapper code")

if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-enum-renames.i)
file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/nlopt-enum-renames.i "// AUTOMATICALLY GENERATED -- DO NOT EDIT\n")
file (STRINGS ${PROJECT_SOURCE_DIR}/src/api/nlopt.h NLOPT_H_LINES REGEX " NLOPT_[A-Z0-9_]+")
Expand Down Expand Up @@ -35,6 +38,7 @@ if (NUMPY_FOUND AND Python_FOUND)
endif ()

set_target_properties (nlopt_python PROPERTIES OUTPUT_NAME nlopt)
set_target_properties (nlopt_python PROPERTIES COMPILE_FLAGS "${SWIG_COMPILE_FLAGS}")

install (FILES ${CMAKE_CURRENT_BINARY_DIR}/nlopt.py DESTINATION ${INSTALL_PYTHON_DIR})
install (TARGETS nlopt_python DESTINATION ${INSTALL_PYTHON_DIR})
Expand All @@ -57,6 +61,7 @@ if (GUILE_FOUND)

swig_link_libraries (nlopt_guile ${nlopt_lib})
target_link_libraries (nlopt_guile ${GUILE_LIBRARIES})
set_target_properties (nlopt_guile PROPERTIES COMPILE_FLAGS "${SWIG_COMPILE_FLAGS}")

file (RELATIVE_PATH _REL_GUILE_SITE_PATH ${GUILE_ROOT_DIR} ${GUILE_SITE_DIR})
set (GUILE_SITE_PATH ${_REL_GUILE_SITE_PATH})
Expand Down

0 comments on commit f24a492

Please sign in to comment.