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

If project define string difinition or have debug compiller options - not work precompile header. #2

Open
talshadow opened this issue Nov 10, 2014 · 3 comments

Comments

@talshadow
Copy link

if some in CMakeLists.txt have :
target_compile_definitions(test-cxx-force PUBLIC OPENFLAG="Open")
build wrong gch file.
if call cmake with -DCMAKE_BUILD_TYPE=Debug
build wrong gch file.
Try this lifehack :)

#export_all_flags("${_pch_flags_file}")
#set(_compiler_FLAGS "@${_pch_flags_file}")
add_custom_command(
OUTPUT "${_pchfile}"
COMMAND "${CMAKE_COMMAND}" -E copy "${_pch_header}" "${_pchfile}"
DEPENDS "${_pch_header}"
COMMENT "Updating ${_name}")
add_custom_command(
OUTPUT "${_output_cxx}"
COMMAND "${CMAKE_CXX_COMPILER}" $(CXX_DEFINES) $(CXX_FLAGS) -x c++-header -o "${_output_cxx}" "${_pchfile}"
DEPENDS "${_pchfile}" "${_pch_flags_file}"
COMMENT "Precompiling ${_name} for ${_target} (C++)")
add_custom_command(
OUTPUT "${_output_c}"
COMMAND "${CMAKE_C_COMPILER}" $(C_DEFINES) $(C_FLAGS) -x c-header -o "${_output_c}" "${_pchfile}"
DEPENDS "${_pchfile}" "${_pch_flags_file}"
COMMENT "Precompiling ${_name} for ${_target} (C)")

@wolfv
Copy link

wolfv commented Mar 29, 2016

I have a similar problem when trying to use C++11.
I defined using C++11 with set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
but it isn't picked up by this the precompiled header.

@phobos2077
Copy link

I have similar issue. I'm using set(CMAKE_CXX_STANDARD 14) but it doesn't got picked up by this script when compiling the header, and so compilation fails.

@bubnikv
Copy link

bubnikv commented Oct 29, 2018

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

will not work. You have to use
add_compile_options(-std=c++11)
instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants