Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output configured NGenConfig header into build directories instead of include directory #681

Closed
program-- opened this issue Nov 22, 2023 · 4 comments · Fixed by #682
Closed
Assignees
Labels
bug Something isn't working build Issues related to CMake and building ngen

Comments

@program--
Copy link
Contributor

program-- commented Nov 22, 2023

Relevant function call:

configure_file("${NGEN_INC_DIR}/NGenConfig.h.in" "${NGEN_INC_DIR}/NGenConfig.h")

Current behavior

Currently, this configure_file call outputs NGenConfig.h into the include/ directory alongside its template. However, this leads to issues in successive out-of-source builds, i.e. CIROH-UA/NGIAB-CloudInfra#50.

Expected behavior

Output and include the configured header to/from the user-specified build directory, so that each out-of-source build has its own NGenConfig.h. (using PROJECT_BINARY_DIR?)

Steps to replicate behavior (include URLs)

git clone https://github.com/NOAA-OWP/ngen.git
cd ngen
cmake -B build_dir_A -S . -DNGEN_WITH_MPI=OFF -DNGEN_WITH_PYTHON=OFF -DNGEN_WITH_TESTS=OFF
cmake -B build_dir_B -S . -DNGEN_WITH_MPI=ON -DNGEN_WITH_PYTHON=OFF -DNGEN_WITH_TESTS=OFF

cat include/NGenConfig.h
#> // NGenConfig.h
#> ...
#> #define NGEN_WITH_MPI 1
#> ...

# Will fail since `build_dir_A` was configured with NGEN_WITH_MPI=OFF, but
# the second configure caused `NGenConfig.h` to have `NGEN_WITH_MPI=ON`.
cmake --build build_dir_A -t ngen
#> ...
#> /ngen/src/NGen.cpp: In function ‘void ngen::exec_info::runtime_summary(std::ostream&)’:
#> /ngen/src/NGen.cpp:67:31: error: ‘mpi_rank’ was not declared in this scope
#>    67 |            << "    Rank: " << mpi_rank << "\n"
#>       |                               ^~~~~~~~
#> /ngen/src/NGen.cpp:68:37: error: ‘mpi_num_procs’ was not declared in this scope
#>    68 |            << "    Processors: " << mpi_num_procs << "\n";
#>       |                                     ^~~~~~~~~~~~~
#> /ngen/src/NGen.cpp: In function ‘int main(int, char**)’:
#> /ngen/src/NGen.cpp:136:9: error: ‘MPI_Init’ was not declared in this scope
#>   136 |         MPI_Init(nullptr, nullptr);
#>       |         ^~~~~~~~
#> /ngen/src/NGen.cpp:137:23: error: ‘MPI_COMM_WORLD’ was not declared in this scope
#>   137 |         MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
#>       |                       ^~~~~~~~~~~~~~
#> /ngen/src/NGen.cpp:137:40: error: ‘mpi_rank’ was not declared in this scope
#>   137 |         MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
#>       |                                        ^~~~~~~~
#> /ngen/src/NGen.cpp:137:9: error: ‘MPI_Comm_rank’ was not declared in this scope
#>   137 |         MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
#>       |         ^~~~~~~~~~~~~
#> /ngen/src/NGen.cpp:138:40: error: ‘mpi_num_procs’ was not declared in this scope
#>   138 |         MPI_Comm_size(MPI_COMM_WORLD, &mpi_num_procs);
#>       |                                        ^~~~~~~~~~~~~
#> /ngen/src/NGen.cpp:138:9: error: ‘MPI_Comm_size’ was not declared in this scope
#>   138 |         MPI_Comm_size(MPI_COMM_WORLD, &mpi_num_procs);
#>       |         ^~~~~~~~~~~~~
#> /ngen/src/NGen.cpp:149:9: error: ‘MPI_Finalize’ was not declared in this scope
#>   149 |         MPI_Finalize();
#>       |         ^~~~~~~~~~~~
#> make[3]: *** [CMakeFiles/ngen.dir/build.make:76: CMakeFiles/ngen.dir/src/NGen.cpp.o] Error 1
#> make[2]: *** [CMakeFiles/Makefile2:307: CMakeFiles/ngen.dir/all] Error 2
#> make[1]: *** [CMakeFiles/Makefile2:314: CMakeFiles/ngen.dir/rule] Error 2
#> make: *** [Makefile:125: ngen] Error 2
@program-- program-- added bug Something isn't working build Issues related to CMake and building ngen labels Nov 22, 2023
@program-- program-- self-assigned this Nov 22, 2023
@program--
Copy link
Contributor Author

program-- commented Nov 27, 2023

Just noticed that this affects https://github.com/NOAA-OWP/ngen/blob/master/src/core/NGen_Python_Build_Versions.in as well if the user's python environment changes (i.e. switches virtual environments between configurations) -- probably will not be as common of an issue, but still something to consider.

@PhilMiller
Copy link
Contributor

Do you want to lump that into the existing PR 682, or address it separately?

@program--
Copy link
Contributor Author

Do you want to lump that into the existing PR 682, or address it separately?

I think I can lump this in real quick, should be pushed up relatively soon

@program--
Copy link
Contributor Author

Addressed in 5c0bd8e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build Issues related to CMake and building ngen
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants