# add\_compile\_options not having an effect

**URL:** https://discourse.cmake.org/t/add-compile-options-not-having-an-effect/5234
**Category:** Usage
**Created:** [March 17, 2022, 12:00am UTC](https://discourse.cmake.org/t/add-compile-options-not-having-an-effect/5234 "2022-03-17T00:00:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ggghamd](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ggghamd/32/1385_2.png) [@ggghamd](https://discourse.cmake.org/u/ggghamd)
#### Post date: [March 17, 2022, 12:00am UTC](https://discourse.cmake.org/t/add-compile-options-not-having-an-effect/5234/1 "2022-03-17T00:00:57Z")

</div>

My linux bin build and runs ok.  
I needed to have compiler options specified and I can see it is set in the build.cmake file after cmake … .  
But now if I compile it, it has no effect on make stage. What could be wrong?

add\_compile\_options(-c -fPIC)  
MakeFiles/lib3.dir/flags.make:9:C\_FLAGS = -c -fPIC  
CMakeFiles/lib2.dir/flags.make:9:C\_FLAGS = -c -fPIC  
CMakeFiles/lib1.dir/flags.make:9:C\_FLAGS = -c -fPIC  
CMakeFiles/test.dir/flags.make:9:C\_FLAGS = -c -fPIC  
Those should generate \*.o files but I instead see \*.a files consistent with static build instead meaning -c and -fPIC no having an effeect on make stage.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 17, 2022, 5:49am UTC](https://discourse.cmake.org/t/add-compile-options-not-having-an-effect/5234/2 "2022-03-17T05:49:54Z")

</div>

`-fPIC` is handled by the [`POSITION_INDEPENDENT_CODE`](https://cmake.org/cmake/help/latest/prop_tgt/POSITION_INDEPENDENT_CODE.html) target property, so that shouldn’t be specified manually. `-c` must be handled by CMake so that the compiler does what CMake expects it to.

What are you trying to accomplish here?
