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
base: staging
from

Conversation

Projects
None yet
8 participants
@nbp
Copy link
Member

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.
@mention-bot

This comment has been minimized.

Copy link

mention-bot commented Aug 18, 2016

@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"

This comment has been minimized.

@ttuegel

ttuegel Aug 18, 2016

Member

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.


if [ -n "$cmakeBuildType" ]; then
cmakeFlags="-DCMAKE_BUILD_TYPE=$cmakeBuildType $cmakeFlags"
elif [ -z "dontAddBuildType" ]; then

This comment has been minimized.

@ttuegel

ttuegel Aug 18, 2016

Member

This should read "$dontAddBuildType, it's missing the $.

A little bikeshedding here: could we call this cmakeDontSetBuildType instead? The cmake prefix matches the other CMake-specific variables. I'm less particular on Set instead of Add, but it sounds like a better verb to me.

@@ -49,7 +49,13 @@ cmakeConfigurePhase() {

# Avoid cmake resetting the rpath of binaries, on make install
# And build always Release, to ensure optimisation flags

This comment has been minimized.

@rasendubi

rasendubi Aug 20, 2016

Member

The comment is now off

@rasendubi rasendubi referenced this pull request Aug 21, 2016

Open

[WIP/RFC] Make `cmakeFlags` more ergonomic #17886

1 of 7 tasks complete
@rasendubi

This comment has been minimized.

Copy link
Member

rasendubi commented Aug 21, 2016

You might be interested in #17886

@aneeshusa

This comment has been minimized.

Copy link
Contributor

aneeshusa commented Aug 21, 2016

@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

This comment has been minimized.

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[@]}"

@rasendubi

This comment has been minimized.

Copy link
Member

rasendubi commented Dec 2, 2018

(triage) Isn't this fixed now?

cmakeBuildType is now supported:

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

@Mic92

This comment has been minimized.

Copy link
Contributor

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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.