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

Add cmakeBuildType and dontAddCmakeBuildType variables to be able to make Debug builds. #17828

Closed
wants to merge 1 commit into from

Conversation

nbp
Copy link
Member

@nbp nbp commented Aug 18, 2016

Motivation for this change

Current cmake setup-tools.sh only allow us to make release builds, and one cannot just remove the command as it is baked in right before calling cmake.

This pull request add the ability to set cmakeBuildType attribute, and default to Release.
This change is likely a mass-rebuild, so I am making this pull request against the staging branch.

Things done
  • Tested using sandboxing
    (nix.useChroot on NixOS,
    or option build-use-chroot in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • OS X
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution with rr.
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@nbp nbp added 0.kind: enhancement Add something new 1.severity: mass-rebuild This PR causes a large number of packages to rebuild 8.has: package (update) This PR updates a package to a newer version labels Aug 18, 2016
@mention-bot
Copy link

@nbp, thanks for your PR! By analyzing the annotation information on this pull request, we identified @ttuegel, @edolstra and @vcunat to be potential reviewers

cmakeFlags="-DCMAKE_SKIP_BUILD_RPATH=ON $cmakeFlags"

if [ -n "$cmakeBuildType" ]; then
cmakeFlags="-DCMAKE_BUILD_TYPE=$cmakeBuildType $cmakeFlags"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one appends -DCMAKE_BUILD_TYPE=Debug to cmakeFlags, does that not override the setting made here? In which case, we need only the dontAddBuildType option.

@rasendubi
Copy link
Member

You might be interested in #17886

@aneeshusa
Copy link
Contributor

@rasendubi Thanks for linking me in! I've added a commit to address this in my PR #17886 - I think this is a prime example of why sets are a more ergonomic approach to cmakeFlags.

@veprbl
Copy link
Member

veprbl commented Aug 22, 2016

Can I suggest doing something like:

diff --git a/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/pkgs/development/tools/build-managers/cmake/setup-hook.sh
--- a/pkgs/development/tools/build-managers/cmake/setup-hook.sh
+++ b/pkgs/development/tools/build-managers/cmake/setup-hook.sh
@@ -48,8 +48,14 @@ cmakeConfigurePhase() {
     cmakeFlags="-DCMAKE_INSTALL_INCLUDEDIR=${!outputDev}/include $cmakeFlags"

     # Avoid cmake resetting the rpath of binaries, on make install
-    # And build always Release, to ensure optimisation flags
-    cmakeFlags="-DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_BUILD_RPATH=ON $cmakeFlags"
+    cmakeFlags="-DCMAKE_SKIP_BUILD_RPATH=ON $cmakeFlags"
+
+    # Allow to build debug version
+    if [ -z "$dontStrip" ] && [ -z "$separateDebugInfo" ]; then
+      cmakeFlags="-DCMAKE_BUILD_TYPE=Release $cmakeFlags"
+    else
+      cmakeFlags="-DCMAKE_BUILD_TYPE=Debug $cmakeFlags"
+    fi

     echo "cmake flags: $cmakeFlags ${cmakeFlagsArray[@]}"

@veprbl veprbl added the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 28, 2018
@rasendubi
Copy link
Member

(triage) Isn't this fixed now?

cmakeBuildType is now supported:

cmakeFlags="-DCMAKE_BUILD_TYPE=${cmakeBuildType:-Release} -DCMAKE_SKIP_BUILD_RPATH=ON $cmakeFlags"

@Mic92
Copy link
Member

Mic92 commented Dec 2, 2018

I think so.

@Mic92 Mic92 closed this Dec 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement Add something new 1.severity: mass-rebuild This PR causes a large number of packages to rebuild 2.status: merge conflict This PR has merge conflicts with the target branch 8.has: package (update) This PR updates a package to a newer version 11.by: nixpkgs-member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants