-
Notifications
You must be signed in to change notification settings - Fork 275
Fix CMake build on Windows #5437
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
Fix CMake build on Windows #5437
Conversation
Without them being required, a new build where the binaries of the two programs are not found fails late and with confusing error messages. This makes the build fail fast and early, at the point where the error is produced (where the binaries have failed to have been found).
The CMakeLists.txt was performing a `cp` command directly, which while it was not an issue on linux, if you build on Windows with cmake, it fails the build because the equivalent command is `copy`. I made it so we use the portable interface of the CMake binary to perform the copy across all targets, so it's portable.
Codecov Report
@@ Coverage Diff @@
## develop #5437 +/- ##
========================================
Coverage 68.21% 68.21%
========================================
Files 1178 1178
Lines 97561 97561
========================================
Hits 66554 66554
Misses 31007 31007
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## develop #5437 +/- ##
========================================
Coverage 68.21% 68.21%
========================================
Files 1178 1178
Lines 97561 97561
========================================
Hits 66554 66554
Misses 31007 31007
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
@@ -1,7 +1,7 @@ | |||
project(CBMC) | |||
|
|||
find_package(BISON) | |||
find_package(FLEX) | |||
find_package(BISON REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 it's a non-optional dependency and absolutely should be marked as REQUIRED
@@ -4,7 +4,7 @@ add_subdirectory(unit) | |||
|
|||
add_custom_target(java-models-library ALL | |||
COMMAND mvn --quiet -Dmaven.test.skip=true package | |||
COMMAND cp target/core-models.jar ${CMAKE_CURRENT_SOURCE_DIR}/src/java_bytecode/library/ | |||
COMMAND ${CMAKE_COMMAND} -E copy target/core-models.jar ${CMAKE_CURRENT_SOURCE_DIR}/src/java_bytecode/library/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, we should avoid using unix-y commands in our... commands.
I'd recommend putting all the variable stuff in "
quotes as well... I don't actually know off the top of my head how CMake handles variable expansions with whitespace in them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's no worse than the current situation so I'm happy for this to be merged as is - but It probably is worth trying a build on a checkout of CBMC that has spaces in its file path. On Mac/Windows it's not that uncommon for this to happen.
@@ -4,7 +4,7 @@ add_subdirectory(unit) | |||
|
|||
add_custom_target(java-models-library ALL | |||
COMMAND mvn --quiet -Dmaven.test.skip=true package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an action for this PR, but we should also avoid hardcoding the maven executable. By adding a configuration for this we could support cases where people want to build with ~/.local/bin/maven-experimental
or whatever.
@@ -4,7 +4,7 @@ add_subdirectory(unit) | |||
|
|||
add_custom_target(java-models-library ALL | |||
COMMAND mvn --quiet -Dmaven.test.skip=true package | |||
COMMAND cp target/core-models.jar ${CMAKE_CURRENT_SOURCE_DIR}/src/java_bytecode/library/ | |||
COMMAND ${CMAKE_COMMAND} -E copy target/core-models.jar ${CMAKE_CURRENT_SOURCE_DIR}/src/java_bytecode/library/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's no worse than the current situation so I'm happy for this to be merged as is - but It probably is worth trying a build on a checkout of CBMC that has spaces in its file path. On Mac/Windows it's not that uncommon for this to happen.
Attempting to build
cbmc
withcmake
onVisual Studio 2019/Win 10
fails.This PR introduces some needed changes to two
CMakeLists.txt
files to makeit work.