add possibility to pass options to cmake via setup.py
This commit is contained in:
parent
8b8e95521f
commit
cfe2823c09
11
test/extra_cmake_options/cmake/autocmake.cfg
Normal file
11
test/extra_cmake_options/cmake/autocmake.cfg
Normal file
@ -0,0 +1,11 @@
|
||||
[project]
|
||||
name: example
|
||||
|
||||
[cxx]
|
||||
source: ../../../modules/cxx.cmake
|
||||
|
||||
[default_build_paths]
|
||||
source: ../../../modules/default_build_paths.cmake
|
||||
|
||||
[src]
|
||||
source: ../../../modules/src.cmake
|
13
test/extra_cmake_options/src/CMakeLists.txt
Normal file
13
test/extra_cmake_options/src/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
# here we test setting -DENABLE_SOMETHING=OFF -DFOO=ON
|
||||
# setup.py script
|
||||
option(ENABLE_SOMETHING "Enable something" ON)
|
||||
option(ENABLE_FOO "Enable FOO" OFF)
|
||||
|
||||
if(ENABLE_SOMETHING)
|
||||
message(FATAL_ERROR "This test failed")
|
||||
endif()
|
||||
if(NOT ENABLE_FOO)
|
||||
message(FATAL_ERROR "This test failed")
|
||||
endif()
|
||||
|
||||
add_executable(example example.cpp)
|
7
test/extra_cmake_options/src/example.cpp
Normal file
7
test/extra_cmake_options/src/example.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Hello World!";
|
||||
return 0;
|
||||
}
|
@ -114,6 +114,13 @@ def test_cxx_custom():
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_extra_cmake_options():
|
||||
stdout, stderr = configure_build_and_exe('extra_cmake_options', 'python setup.py --cxx=g++ --cmake-options="-DENABLE_SOMETHING=OFF -DENABLE_FOO=ON"')
|
||||
assert 'Hello World!' in stdout
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_cxx():
|
||||
stdout, stderr = configure_build_and_exe('cxx', 'python setup.py --cxx=g++')
|
||||
assert 'Hello World!' in stdout
|
||||
|
@ -102,6 +102,8 @@ def gen_cmake_command(config):
|
||||
|
||||
s.append(" command.append('-DCMAKE_BUILD_TYPE=%s' % arguments['--type'])")
|
||||
s.append(" command.append('-G \"%s\"' % arguments['--generator'])")
|
||||
s.append(" for word in arguments['--cmake-options'].split():")
|
||||
s.append(" command.append('%s' % word)")
|
||||
|
||||
s.append("\n return ' '.join(command)")
|
||||
|
||||
@ -151,6 +153,7 @@ def gen_setup(config, relative_path):
|
||||
options.append(['--type=<TYPE>', 'Set the CMake build type (debug, release, or relwithdeb) [default: release].'])
|
||||
options.append(['--generator=<STRING>', 'Set the CMake build system generator [default: Unix Makefiles].'])
|
||||
options.append(['--show', 'Show CMake command and exit.'])
|
||||
options.append(['--cmake-options=<OPTIONS>', 'Define options to CMake [default: None].'])
|
||||
options.append(['<builddir>', 'Build directory.'])
|
||||
options.append(['-h --help', 'Show this screen.'])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user