Loaden | 6 Sep 2012 00:30
Picon
Gravatar

Add sources to a target library after add_library()?

Hi, I look this ML: http://www.cmake.org/pipermail/cmake/2010-January/034437.html
Does CMake still can't support how to add sources to a target library after add_library()?
I wan't support Precompiled Header for both MSVC / GCC(MinGW).
In MSVC case, it need a source, e.g. StdAfx.cpp to support PCH.
But in GCC case, it only need a header, e.g. pch.h
Any help or comments or tips are best welcome!
See: https://codereview.qt-project.org/#change,34052

--

Best Regards
Yuchen

--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Mathias Gaunard | 6 Sep 2012 03:34

Re: Add sources to a target library after add_library()?

On 06/09/2012 00:30, Loaden wrote:
> Hi, I look this ML:
> http://www.cmake.org/pipermail/cmake/2010-January/034437.html
> Does CMake still can't support how to add sources to a target library
> after add_library()?
> I wan't support Precompiled Header for both MSVC / GCC(MinGW).
> In MSVC case, it need a source, e.g. StdAfx.cpp to support PCH.
> But in GCC case, it only need a header, e.g. pch.h
> Any help or comments or tips are best welcome!
> See: https://codereview.qt-project.org/#change,34052

I don't see what this feature would have to do with precompiled headers.

To use a precompiled header with GCC, just add -include 
path/to/precompiled/header.hpp to your compilation flags, and make sure 
you've built path/to/precompiled/header.hpp.gch before that.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Loaden | 6 Sep 2012 07:51
Picon
Gravatar

Re: Add sources to a target library after add_library()?

Yes, it simply for GCC. But it is diffrent for MSVC compiler.
for MSVC, we have to use a .cpp file, e.g. stdafx.cpp to support precompiled. (/Yc flags)
For now, I have to implement it like this to support both MSVC and GCC's PCH support.
set(target Core)
if (QTCREATOR_PRECOMPILED AND MSVC)
    set(precompiled libpch.cpp)
endif()
set(sources
    lib.cpp
    lib2.cpp
)
add_qtcreator_plugin(${target}
    ${sources}
    ${precompiled}
)
add_dependencies(${target} Botan)
if (QTCREATOR_PRECOMPILED)
    add_precompiled_header(${target} "CXX" libpch.h ${precompiled})
    use_precompiled_header(${target} "${sources}")
endif()
 
 
2012/9/6 Mathias Gaunard <mathias.gaunard-vYW+cPY1g1pg9hUCZPvPmw@public.gmane.org>
To use a precompiled header with GCC, just add -include path/to/precompiled/header.hpp to your compilation flags, and make sure you've built path/to/precompiled/header.hpp.gch before that.



--
Best Regards
Yuchen

--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Gmane