diff --git a/autocmake/generate.py b/autocmake/generate.py index ee0c422..37a4e23 100644 --- a/autocmake/generate.py +++ b/autocmake/generate.py @@ -45,7 +45,7 @@ def autogenerated_notice(): return '\n'.join(s) -def gen_setup(config, relative_path, setup_script_name): +def gen_setup(config, default_build_type, relative_path, setup_script_name): """ Generate setup script. """ @@ -76,7 +76,7 @@ def gen_setup(config, relative_path, setup_script_name): rest = ' '.join(opt.split()[1:]).strip() options.append([first, rest]) - options.append(['--type=', 'Set the CMake build type (debug, release, or relwithdeb) [default: release].']) + options.append(['--type=', 'Set the CMake build type (debug, release, relwithdebinfo, minsizerel) [default: {0}].'.format(default_build_type)]) options.append(['--generator=', 'Set the CMake build system generator [default: Unix Makefiles].']) options.append(['--show', 'Show CMake command and exit.']) options.append(['--cmake-executable=', 'Set the CMake executable [default: cmake].']) @@ -118,7 +118,7 @@ def gen_setup(config, relative_path, setup_script_name): return s -def gen_cmakelists(project_name, min_cmake_version, relative_path, modules): +def gen_cmakelists(project_name, min_cmake_version, default_build_type, relative_path, modules): """ Generate CMakeLists.txt. """ @@ -137,9 +137,14 @@ def gen_cmakelists(project_name, min_cmake_version, relative_path, modules): s.append('\n# do not rebuild if rules (compiler flags) change') s.append('set(CMAKE_SKIP_RULE_DEPENDENCY TRUE)') + build_type_capitalized = {'debug': 'Debug', + 'release': 'Release', + 'relwithdebinfo': 'RelWithDebInfo', + 'minsizerel': 'MinSizeRel'} + s.append('\n# if CMAKE_BUILD_TYPE undefined, we set it to Debug') s.append('if(NOT CMAKE_BUILD_TYPE)') - s.append(' set(CMAKE_BUILD_TYPE "Debug")') + s.append(' set(CMAKE_BUILD_TYPE "{0}")'.format(build_type_capitalized[default_build_type])) s.append('endif()') if len(modules) > 0: diff --git a/test/boost_header_only/cmake/autocmake.yml b/test/boost_header_only/cmake/autocmake.yml index 3b319b1..7ab720b 100644 --- a/test/boost_header_only/cmake/autocmake.yml +++ b/test/boost_header_only/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - cxx: - source: ../../../modules/cxx.cmake diff --git a/test/boost_libs/cmake/autocmake.yml b/test/boost_libs/cmake/autocmake.yml index 43f5d47..0ae1ebe 100644 --- a/test/boost_libs/cmake/autocmake.yml +++ b/test/boost_libs/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - cxx: - source: ../../../modules/cxx.cmake diff --git a/test/cxx/cmake/autocmake.yml b/test/cxx/cmake/autocmake.yml index 5bfe461..7b24802 100644 --- a/test/cxx/cmake/autocmake.yml +++ b/test/cxx/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - cxx: - source: ../../../modules/cxx.cmake diff --git a/test/cxx_accelerate/cmake/autocmake.yml b/test/cxx_accelerate/cmake/autocmake.yml index c2fccf4..e3d429a 100644 --- a/test/cxx_accelerate/cmake/autocmake.yml +++ b/test/cxx_accelerate/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - cxx: - source: ../../../modules/cxx.cmake diff --git a/test/cxx_cblas/cmake/autocmake.yml b/test/cxx_cblas/cmake/autocmake.yml index 6df6437..567009e 100644 --- a/test/cxx_cblas/cmake/autocmake.yml +++ b/test/cxx_cblas/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - cxx: - source: ../../../modules/cxx.cmake diff --git a/test/extra_cmake_options/cmake/autocmake.yml b/test/extra_cmake_options/cmake/autocmake.yml index 5bfe461..7b24802 100644 --- a/test/extra_cmake_options/cmake/autocmake.yml +++ b/test/extra_cmake_options/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - cxx: - source: ../../../modules/cxx.cmake diff --git a/test/fc/cmake/autocmake.yml b/test/fc/cmake/autocmake.yml index 7d2318c..0bca6cf 100644 --- a/test/fc/cmake/autocmake.yml +++ b/test/fc/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - fc: - source: ../../../modules/fc.cmake diff --git a/test/fc_blas/cmake/autocmake.yml b/test/fc_blas/cmake/autocmake.yml index 0ed452b..1f390cf 100644 --- a/test/fc_blas/cmake/autocmake.yml +++ b/test/fc_blas/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - fc: - source: ../../../modules/fc.cmake diff --git a/test/fc_git_info/cmake/autocmake.yml b/test/fc_git_info/cmake/autocmake.yml index af54162..5fb3b29 100644 --- a/test/fc_git_info/cmake/autocmake.yml +++ b/test/fc_git_info/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - fc: - source: ../../../modules/fc.cmake diff --git a/test/fc_int64/cmake/autocmake.yml b/test/fc_int64/cmake/autocmake.yml index 0cc3d23..3d8f5f3 100644 --- a/test/fc_int64/cmake/autocmake.yml +++ b/test/fc_int64/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - fc: - source: ../../../modules/fc.cmake diff --git a/test/fc_lapack/cmake/autocmake.yml b/test/fc_lapack/cmake/autocmake.yml index fa696e5..914522e 100644 --- a/test/fc_lapack/cmake/autocmake.yml +++ b/test/fc_lapack/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - fc: - source: ../../../modules/fc.cmake diff --git a/test/fc_omp/cmake/autocmake.yml b/test/fc_omp/cmake/autocmake.yml index 09596a6..e45bdeb 100644 --- a/test/fc_omp/cmake/autocmake.yml +++ b/test/fc_omp/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - fc: - source: ../../../modules/fc.cmake diff --git a/test/python_interpreter/cmake/autocmake.yml b/test/python_interpreter/cmake/autocmake.yml index 560fd7e..7cc0d91 100644 --- a/test/python_interpreter/cmake/autocmake.yml +++ b/test/python_interpreter/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - cxx: - source: ../../../modules/cxx.cmake diff --git a/test/python_interpreter_custom/cmake/autocmake.yml b/test/python_interpreter_custom/cmake/autocmake.yml index 1bb701d..c547d70 100644 --- a/test/python_interpreter_custom/cmake/autocmake.yml +++ b/test/python_interpreter_custom/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - cxx: - source: ../../../modules/cxx.cmake diff --git a/test/python_libs/cmake/autocmake.yml b/test/python_libs/cmake/autocmake.yml index 560fd7e..7cc0d91 100644 --- a/test/python_libs/cmake/autocmake.yml +++ b/test/python_libs/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - cxx: - source: ../../../modules/cxx.cmake diff --git a/test/python_libs_custom/cmake/autocmake.yml b/test/python_libs_custom/cmake/autocmake.yml index 560fd7e..7cc0d91 100644 --- a/test/python_libs_custom/cmake/autocmake.yml +++ b/test/python_libs_custom/cmake/autocmake.yml @@ -1,5 +1,6 @@ name: example min_cmake_version: 2.8 +default_build_type: debug modules: - cxx: - source: ../../../modules/cxx.cmake diff --git a/update.py b/update.py index 9508edd..e0d2f1a 100644 --- a/update.py +++ b/update.py @@ -147,6 +147,12 @@ def process_yaml(argv): sys.stderr.write("ERROR: you have to specify min_cmake_version in autocmake.yml\n") sys.exit(-1) + if 'default_build_type' in config: + default_build_type = config['default_build_type'].lower() + else: + sys.stderr.write("ERROR: you have to specify default_build_type in autocmake.yml\n") + sys.exit(-1) + if 'setup_script' in config: setup_script_name = config['setup_script'] else: @@ -173,13 +179,13 @@ def process_yaml(argv): # create CMakeLists.txt print('- generating CMakeLists.txt') - s = gen_cmakelists(project_name, min_cmake_version, relative_path, modules) + s = gen_cmakelists(project_name, min_cmake_version, default_build_type, relative_path, modules) with open(os.path.join(project_root, 'CMakeLists.txt'), 'w') as f: f.write('{0}\n'.format('\n'.join(s))) # create setup script print('- generating setup script') - s = gen_setup(cleaned_config, relative_path, setup_script_name) + s = gen_setup(cleaned_config, default_build_type, relative_path, setup_script_name) file_path = os.path.join(project_root, setup_script_name) with open(file_path, 'w') as f: f.write('{0}\n'.format('\n'.join(s)))