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

No rule to make target 'generated/ottdres.rc' when Cross-compiling with CMake + MINGW #9329

Closed
Roboron3042 opened this issue Jun 2, 2021 · 7 comments

Comments

@Roboron3042
Copy link

I'm unable to cross-compile OpenTTD (master) inside a MINGW environment using CMake due to the aforementioned error.

Things I did:

In the toolchain file I've everything set up correctly, as I used it before to build other projects. Either there is something I didn't do previously (probably, since openttd cross-compilation with cmake is not well documented), or there is something missing in CMake files.

@James103
Copy link
Contributor

James103 commented Jun 2, 2021

What version of OpenTTD did you try to build?

@Roboron3042
Copy link
Author

What version of OpenTTD did you try to build?

The current master (I already said it).

@glx22
Copy link
Contributor

glx22 commented Jun 2, 2021

Cross-compilation is tested with every nightly build, so it should work.
Please provide all the exact steps you followed, including the tool build steps.

Edit: hmm 'generated/ottdres.rc' doesn't depend on openttd native tools, it should be generated by version detection script during build

@glx22
Copy link
Contributor

glx22 commented Jun 2, 2021

I think the issue is

if(WIN32)
message(STATUS "Generating ottdres.rc")
configure_file("${CMAKE_SOURCE_DIR}/src/os/windows/ottdres.rc.in"
"${FIND_VERSION_BINARY_DIR}/ottdres.rc")
endif()

I'm not sure WIN32 is set properly for cmake calls in add_custom_target like

OpenTTD/CMakeLists.txt

Lines 73 to 83 in 48ecc48

add_custom_target(find_version
${CMAKE_COMMAND}
-DFIND_VERSION_BINARY_DIR=${CMAKE_BINARY_DIR}/generated
-DCPACK_BINARY_DIR=${CMAKE_BINARY_DIR}
-DREV_MAJOR=${PROJECT_VERSION_MAJOR}
-DREV_MINOR=${PROJECT_VERSION_MINOR}
-DREV_BUILD=${PROJECT_VERSION_PATCH}
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/FindVersion.cmake"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
BYPRODUCTS ${GENERATED_SOURCE_FILES}
)

But I can't really test it myself.

@Roboron3042
Copy link
Author

Roboron3042 commented Jun 2, 2021

I think the issue is

if(WIN32)
message(STATUS "Generating ottdres.rc")
configure_file("${CMAKE_SOURCE_DIR}/src/os/windows/ottdres.rc.in"
"${FIND_VERSION_BINARY_DIR}/ottdres.rc")
endif()

Yes it is. I removed the IF condition and compilation continued (but didn't succeed due to an unrelated error), so you are right.

glx22 added a commit to glx22/OpenTTD that referenced this issue Jun 2, 2021
@glx22
Copy link
Contributor

glx22 commented Jun 2, 2021

Ok master...glx22:fix_9329 should fix it, but I only tested native builds.

@Roboron3042
Copy link
Author

Roboron3042 commented Jun 2, 2021

I've applied the patch to my local copy and I can confirm it fixed the issue. I have now other issues preventing me from compiling, but I'll report them on another issue since they don't seem to be related.

@glx22 glx22 closed this as completed in 076f3d2 Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants