Merge pull request #221 from robertodr/bare-cmake
Get setup to reproduce use of bare CMake
This commit is contained in:
		
							
								
								
									
										19
									
								
								.default.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								.default.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | with import <nixpkgs> {}; { | ||||||
|  |   autocmakeEnv = stdenv.mkDerivation { | ||||||
|  |     name = "Autocmake"; | ||||||
|  |     buildInputs = [ | ||||||
|  |       atlas | ||||||
|  |       ccache | ||||||
|  |       clang | ||||||
|  |       cmake | ||||||
|  |       doxygen | ||||||
|  |       gfortran | ||||||
|  |       liblapack | ||||||
|  |       openmpi | ||||||
|  |       python35Packages.pep8 | ||||||
|  |       python35Packages.pytest | ||||||
|  |       python35Packages.pyyaml | ||||||
|  |       zlib | ||||||
|  |     ]; | ||||||
|  |   }; | ||||||
|  | } | ||||||
							
								
								
									
										7
									
								
								.envrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								.envrc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  | use nix .default.nix | ||||||
|  | export SOURCE_DATE_EPOCH=$(date +%s) | ||||||
|  | dir_hash=autocmake-$(echo -n autocmake | shasum | cut -d ' ' -f 1) | ||||||
|  | direnv_layout_dir=$XDG_CACHE_HOME/direnv/layouts/$dir_hash | ||||||
|  | layout python `type -P python` --system-site-packages | ||||||
|  | pip install -r requirements.txt | ||||||
|  | export NINJA_STATUS="[Built edge %f of %t in %e sec]" | ||||||
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -10,6 +10,7 @@ test/*/cmake/update.py | |||||||
| test/*/cmake/autocmake/ | test/*/cmake/autocmake/ | ||||||
| test/*/cmake/downloaded/ | test/*/cmake/downloaded/ | ||||||
| test/*/setup | test/*/setup | ||||||
|  | test/*/cmake_output | ||||||
|  |  | ||||||
| # generated by doc/extract_rst.py | # generated by doc/extract_rst.py | ||||||
| doc/module-reference.rst | doc/module-reference.rst | ||||||
|   | |||||||
| @@ -48,34 +48,6 @@ def setup_build_path(build_path): | |||||||
|         os.makedirs(build_path, 0o755) |         os.makedirs(build_path, 0o755) | ||||||
|  |  | ||||||
|  |  | ||||||
| def test_adapt_cmake_command_to_platform(): |  | ||||||
|  |  | ||||||
|     cmake_command = "FC=foo CC=bar CXX=RABOOF cmake -DTHIS -DTHAT='this and that cmake' .." |  | ||||||
|     res = adapt_cmake_command_to_platform(cmake_command, 'linux') |  | ||||||
|     assert res == cmake_command |  | ||||||
|     res = adapt_cmake_command_to_platform(cmake_command, 'win32') |  | ||||||
|     assert res == "set FC=foo && set CC=bar && set CXX=RABOOF && cmake -DTHIS -DTHAT='this and that cmake' .." |  | ||||||
|  |  | ||||||
|     cmake_command = "cmake -DTHIS -DTHAT='this and that cmake' .." |  | ||||||
|     res = adapt_cmake_command_to_platform(cmake_command, 'linux') |  | ||||||
|     assert res == cmake_command |  | ||||||
|     res = adapt_cmake_command_to_platform(cmake_command, 'win32') |  | ||||||
|     assert res == cmake_command |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def adapt_cmake_command_to_platform(cmake_command, platform): |  | ||||||
|     """ |  | ||||||
|     Adapt CMake command to MS Windows platform. |  | ||||||
|     """ |  | ||||||
|     if platform == 'win32': |  | ||||||
|         pos = cmake_command.find('cmake') |  | ||||||
|         s = ['set {0} &&'.format(e) for e in cmake_command[:pos].split()] |  | ||||||
|         s.append(cmake_command[pos:]) |  | ||||||
|         return ' '.join(s) |  | ||||||
|     else: |  | ||||||
|         return cmake_command |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def run_cmake(command, build_path, default_build_path): | def run_cmake(command, build_path, default_build_path): | ||||||
|     """ |     """ | ||||||
|     Execute CMake command. |     Execute CMake command. | ||||||
| @@ -84,7 +56,6 @@ def run_cmake(command, build_path, default_build_path): | |||||||
|     from shutil import rmtree |     from shutil import rmtree | ||||||
|  |  | ||||||
|     topdir = os.getcwd() |     topdir = os.getcwd() | ||||||
|     os.chdir(build_path) |  | ||||||
|     p = Popen(command, |     p = Popen(command, | ||||||
|               shell=True, |               shell=True, | ||||||
|               stdin=PIPE, |               stdin=PIPE, | ||||||
| @@ -164,8 +135,7 @@ def configure(root_directory, build_path, cmake_command, only_show): | |||||||
|     if not only_show: |     if not only_show: | ||||||
|         setup_build_path(build_path) |         setup_build_path(build_path) | ||||||
|  |  | ||||||
|     cmake_command = adapt_cmake_command_to_platform(cmake_command, sys.platform) |     cmake_command += ' -B' + build_path | ||||||
|  |  | ||||||
|     print('{0}\n'.format(cmake_command)) |     print('{0}\n'.format(cmake_command)) | ||||||
|     if only_show: |     if only_show: | ||||||
|         sys.exit(0) |         sys.exit(0) | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ def gen_cmake_command(config): | |||||||
|         s.append('    command.append({0})'.format(definition)) |         s.append('    command.append({0})'.format(definition)) | ||||||
|  |  | ||||||
|     s.append("    command.append('-DCMAKE_BUILD_TYPE={0}'.format(arguments['--type']))") |     s.append("    command.append('-DCMAKE_BUILD_TYPE={0}'.format(arguments['--type']))") | ||||||
|     s.append("    command.append('-G \"{0}\"'.format(arguments['--generator']))") |     s.append("    command.append('-G\"{0}\"'.format(arguments['--generator']))") | ||||||
|     s.append("    if arguments['--cmake-options'] != \"''\":") |     s.append("    if arguments['--cmake-options'] != \"''\":") | ||||||
|     s.append("        command.append(arguments['--cmake-options'])") |     s.append("        command.append(arguments['--cmake-options'])") | ||||||
|     s.append("    if arguments['--prefix']:") |     s.append("    if arguments['--prefix']:") | ||||||
| @@ -110,7 +110,7 @@ def gen_setup(config, default_build_type, relative_path, setup_script_name): | |||||||
|     s.append("build_path = arguments['<builddir>']") |     s.append("build_path = arguments['<builddir>']") | ||||||
|     s.append("\n") |     s.append("\n") | ||||||
|     s.append("# create cmake command") |     s.append("# create cmake command") | ||||||
|     s.append("cmake_command = '{0} {1}'.format(gen_cmake_command(options, arguments), root_directory)") |     s.append("cmake_command = '{0} -H{1}'.format(gen_cmake_command(options, arguments), root_directory)") | ||||||
|     s.append("\n") |     s.append("\n") | ||||||
|     s.append("# run cmake") |     s.append("# run cmake") | ||||||
|     s.append("configure.configure(root_directory, build_path, cmake_command, arguments['--show'])") |     s.append("configure.configure(root_directory, build_path, cmake_command, arguments['--show'])") | ||||||
|   | |||||||
| @@ -25,8 +25,7 @@ | |||||||
| #   docopt: | #   docopt: | ||||||
| #     - "--cc=<CC> C compiler [default: gcc]." | #     - "--cc=<CC> C compiler [default: gcc]." | ||||||
| #     - "--extra-cc-flags=<EXTRA_CFLAGS> Extra C compiler flags [default: '']." | #     - "--extra-cc-flags=<EXTRA_CFLAGS> Extra C compiler flags [default: '']." | ||||||
| #   export: "'CC={0}'.format(arguments['--cc'])" | #   define: "'-DCMAKE_C_COMPILER={0} -DEXTRA_CFLAGS=\"{1}\"'.format(arguments['--cc'], arguments['--extra-cc-flags'])" | ||||||
| #   define: "'-DEXTRA_CFLAGS=\"{0}\"'.format(arguments['--extra-cc-flags'])" |  | ||||||
|  |  | ||||||
| if(NOT DEFINED CMAKE_C_COMPILER_ID) | if(NOT DEFINED CMAKE_C_COMPILER_ID) | ||||||
|     message(FATAL_ERROR "CMAKE_C_COMPILER_ID variable is not defined!") |     message(FATAL_ERROR "CMAKE_C_COMPILER_ID variable is not defined!") | ||||||
|   | |||||||
| @@ -25,8 +25,7 @@ | |||||||
| #   docopt: | #   docopt: | ||||||
| #     - "--cxx=<CXX> C++ compiler [default: g++]." | #     - "--cxx=<CXX> C++ compiler [default: g++]." | ||||||
| #     - "--extra-cxx-flags=<EXTRA_CXXFLAGS> Extra C++ compiler flags [default: '']." | #     - "--extra-cxx-flags=<EXTRA_CXXFLAGS> Extra C++ compiler flags [default: '']." | ||||||
| #   export: "'CXX={0}'.format(arguments['--cxx'])" | #   define: "'-DCMAKE_CXX_COMPILER={0} -DEXTRA_CXXFLAGS=\"{1}\"'.format(arguments['--cxx'], arguments['--extra-cxx-flags'])" | ||||||
| #   define: "'-DEXTRA_CXXFLAGS=\"{0}\"'.format(arguments['--extra-cxx-flags'])" |  | ||||||
|  |  | ||||||
| if(NOT DEFINED CMAKE_CXX_COMPILER_ID) | if(NOT DEFINED CMAKE_CXX_COMPILER_ID) | ||||||
|     message(FATAL_ERROR "CMAKE_CXX_COMPILER_ID variable is not defined!") |     message(FATAL_ERROR "CMAKE_CXX_COMPILER_ID variable is not defined!") | ||||||
|   | |||||||
| @@ -29,8 +29,7 @@ | |||||||
| #   docopt: | #   docopt: | ||||||
| #     - "--fc=<FC> Fortran compiler [default: gfortran]." | #     - "--fc=<FC> Fortran compiler [default: gfortran]." | ||||||
| #     - "--extra-fc-flags=<EXTRA_FCFLAGS> Extra Fortran compiler flags [default: '']." | #     - "--extra-fc-flags=<EXTRA_FCFLAGS> Extra Fortran compiler flags [default: '']." | ||||||
| #   export: "'FC={0}'.format(arguments['--fc'])" | #   define: "'-DCMAKE_Fortran_COMPILER={0} -DEXTRA_FCFLAGS=\"{1}\"'.format(arguments['--fc'], arguments['--extra-fc-flags'])" | ||||||
| #   define: "'-DEXTRA_FCFLAGS=\"{0}\"'.format(arguments['--extra-fc-flags'])" |  | ||||||
|  |  | ||||||
| set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules) | set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules) | ||||||
| include_directories(${PROJECT_BINARY_DIR}/modules) | include_directories(${PROJECT_BINARY_DIR}/modules) | ||||||
|   | |||||||
| @@ -35,9 +35,8 @@ | |||||||
| #     - "--fc=<FC> Fortran compiler [default: gfortran]." | #     - "--fc=<FC> Fortran compiler [default: gfortran]." | ||||||
| #     - "--extra-fc-flags=<EXTRA_FCFLAGS> Extra Fortran compiler flags [default: '']." | #     - "--extra-fc-flags=<EXTRA_FCFLAGS> Extra Fortran compiler flags [default: '']." | ||||||
| #     - "--fc-support=<FC_SUPPORT> Toggle Fortran language support (ON/OFF) [default: ON]." | #     - "--fc-support=<FC_SUPPORT> Toggle Fortran language support (ON/OFF) [default: ON]." | ||||||
| #   export: "'FC={0}'.format(arguments['--fc'])" |  | ||||||
| #   define: | #   define: | ||||||
| #     - "'-DEXTRA_FCFLAGS=\"{0}\"'.format(arguments['--extra-fc-flags'])" | #     - "'-DCMAKE_Fortran_COMPILER={0} -DEXTRA_FCFLAGS=\"{1}\"'.format(arguments['--fc'], arguments['--extra-fc-flags'])" | ||||||
| #     - "'-DENABLE_FC_SUPPORT={0}'.format(arguments['--fc-support'])" | #     - "'-DENABLE_FC_SUPPORT={0}'.format(arguments['--fc-support'])" | ||||||
|  |  | ||||||
| option(ENABLE_FC_SUPPORT "Enable Fortran language support" ON) | option(ENABLE_FC_SUPPORT "Enable Fortran language support" ON) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user