# CMake Flag to CustomApp not to read \`slicerrc.py\` or define other file?

**URL:** <https://discourse.slicer.org/t/cmake-flag-to-customapp-not-to-read-slicerrc-py-or-define-other-file/39046>\
**Category:** Development\
**Created:** [September 28, 2024, 5:10pm UTC](https://discourse.slicer.org/t/cmake-flag-to-customapp-not-to-read-slicerrc-py-or-define-other-file/39046 "2024-09-28T17:10:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![apparrilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/apparrilla/32/9230_2.png) [@apparrilla](https://discourse.slicer.org/u/apparrilla)\
**Post date:** [September 28, 2024, 5:10pm UTC](https://discourse.slicer.org/t/cmake-flag-to-customapp-not-to-read-slicerrc-py-or-define-other-file/39046/1 "2024-09-28T17:10:17Z")

</div>

Hi everyone!  
I´ve some trouble betweeen CustomApp and normal Slicer because first one read slicerrc.py file. Is ther any way to complie CustomApp not to read this file or define a custom rc file to be saved instead?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 29, 2024, 3:39am UTC](https://discourse.slicer.org/t/cmake-flag-to-customapp-not-to-read-slicerrc-py-or-define-other-file/39046/2 "2024-09-29T03:39:04Z")

</div>

Good catch! Custom Slicer applications should be completely independent from standard 3D Slicer applications. By default, a custom application’s startup script name should be determined by the application name, such as `.<applicationname>rc.py`.

It should be also possible to disable using a startup script for a custom application. It is probably already feasible by setting a custom environment variable in the launcher or by passing `--ignore-slicerrc` argument to the main application in the launcher, but it would be nice to have a dedicated CMake option or application configuration flag for it.

@jcfr @pieper scary do you think?

---

<div class="post-metadata">

**Author:** ![apparrilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/apparrilla/32/9230_2.png) [@apparrilla](https://discourse.slicer.org/u/apparrilla)\
**Post date:** [September 29, 2024, 6:30am UTC](https://discourse.slicer.org/t/cmake-flag-to-customapp-not-to-read-slicerrc-py-or-define-other-file/39046/3 "2024-09-29T06:30:22Z")

</div>

Even should be nice to link it to “Slicer\_STORE\_SETTINGS\_IN\_APPLICATION\_HOME\_DIR” flag not to loose portability…

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 29, 2024, 12:19pm UTC](https://discourse.slicer.org/t/cmake-flag-to-customapp-not-to-read-slicerrc-py-or-define-other-file/39046/4 "2024-09-29T12:19:40Z")

</div>

Agreed, the custom app should be completely independent of Slicer in terms of settings, rc file, etc.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [September 30, 2024, 1:44pm UTC](https://discourse.slicer.org/t/cmake-flag-to-customapp-not-to-read-slicerrc-py-or-define-other-file/39046/5 "2024-09-30T13:44:19Z")

</div>

In the past, we have applied a patch like the following. Generalizing as discussed above would indeed be sensible.

```diff
diff --git a/Base/QTCore/qSlicerCoreCommandOptions.cxx b/Base/QTCore/qSlicerCoreCommandOptions.cxx
index 41bc603fb53..df309efdb5b 100644
--- a/Base/QTCore/qSlicerCoreCommandOptions.cxx
+++ b/Base/QTCore/qSlicerCoreCommandOptions.cxx
@@ -128,8 +128,9 @@ bool qSlicerCoreCommandOptions::ignoreRest() const
 bool qSlicerCoreCommandOptions::ignoreSlicerRC()const
 {
   Q_D(const qSlicerCoreCommandOptions);
- return d->ParsedArgs.value("ignore-slicerrc").toBool() ||
- this->isTestingEnabled();
+ //return d->ParsedArgs.value("ignore-slicerrc").toBool() ||
+ // this->isTestingEnabled();
+ return true;
 }

```

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [September 30, 2024, 1:57pm UTC](https://discourse.slicer.org/t/cmake-flag-to-customapp-not-to-read-slicerrc-py-or-define-other-file/39046/6 "2024-09-30T13:57:38Z")

</div>

@apparrilla I have been using conditions like this to differentiate how the slicerrc file is used in each case. This may be useful in the short term.

```auto
if slicer.app.mainApplicationName == 'Slicer':

```

If we are redesigning this part, I suggest moving the file to another place, to decrease the number of paths where relevant Slicer related files are stored, and to make it easier to find files for any given application. More concretely, the user folder’s root only contains this one file, but I think we could move it to where the app’s main configuration file is located: `AppData/Roaming/[org.name]` (on Windows). Then we may want to change its name as well to correspond to the application name.

---

<div class="post-metadata">

**Author:** ![apparrilla](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/apparrilla/32/9230_2.png) [@apparrilla](https://discourse.slicer.org/u/apparrilla)\
**Post date:** [February 11, 2026, 5:44pm UTC](https://discourse.slicer.org/t/cmake-flag-to-customapp-not-to-read-slicerrc-py-or-define-other-file/39046/7 "2026-02-11T17:44:52Z")

</div>

Hi everyone again!

Is there any update for this task? Is there any new flag to add to CMakeList.txt to redirect my CustomSlicer to an internal rc.py saved in anywhere as c:/user/applicationname/?

Thanks on advance!

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [June 17, 2026, 11:43am UTC](https://discourse.slicer.org/t/cmake-flag-to-customapp-not-to-read-slicerrc-py-or-define-other-file/39046/8 "2026-06-17T11:43:56Z")

</div>

I have issued the following PR to address items mentioned here so that custom apps use a custom app named rc file or can configure in a build option to turn off rc file support.

> <https://github.com/Slicer/Slicer/pull/9240>
>
> This addresses the items discussed in https://discourse.slicer.org/t/cmake-flag-…to-customapp-not-to-read-slicerrc-py-or-define-other-file/39046.
> 
> 1. Per \[comment\](https://discourse.slicer.org/t/cmake-flag-to-customapp-not-to-read-slicerrc-py-or-define-other-file/39046/6?u=jamesobutler) the default location when no existing rc files exists is now the slicerHome location rather than in the user directory root.
> 2. .slicerrc.py is no longer used by Slicer custom applications, but instead use their own application named rc file \`.\<mainApplicationName\>rc.py\`. 
> 3. Slicer custom applications can also configure to turn off application RC startup script usage entirely with a new build option \`Slicer\_USE\_SLICERRC\`. This is by default on, but can be configured to be turned off. When the app configures it off, the settings dialog entry for specifying the startup path location is hidden as well as the command line flag \`ignore-slicerrc\` not being added as it would be irrelevant.
