[CMake] How to use CMAKE_MFC_FLAG for only one on executables?

Nicholas Braden nicholas11braden at gmail.com
Wed Jun 1 08:34:59 EDT 2016


Have you tried unsetting it after adding the executable in question?
If that doesn't work, is it possible to make the MFX executable be the
very last executable added in your project?

On Wed, Jun 1, 2016 at 4:50 AM, Zhang Peixuan <zhangpeixuan.cn at gmail.com> wrote:
> Hello All,
>
> I want to use CMake to manage my MFC projects, and I added the following
> code:
>
>     set( CMAKE_MFC_FLAG 2)
>     add_executable(MFCDemo WIN32
>         ${MFC_RESOURCE_FILES}
>         ${MFC_HEADER_FILES}
>         ${MFC_SOURCE_FILES}
>         )
>     target_compile_definitions(MFCDemo
>         PUBLIC -D_AFXDLL=1
>         PUBLIC -D_UNICODE
>         PUBLIC -DUNICODE
>         )
>
> It works.
> However, my question is that: In addition to the MFC executable, I still
> have some non-MFC executables,
> and once CMAKE_MFC_FLAG is set, all the add_executables' property should be
> "Use MFC in a Shared DLL".
> In fact, I want only one MFC executable, and make sure all other executables
> are "Use Standard Windows Library".
> Is there any way to implement it? It seems CMAKE_MFC_FLAG does not work with
> set_target_property or other commands.
>
> Thanks,
> Peixuan Zhang
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list