[CMake] Problem with different #include for precompiled Headers

Omar Valerio omar.valerio at gmail.com
Wed Mar 4 08:46:14 EST 2015


Hello Matthieu,

Yes, using "../stdafx.h"  in your include statements in main.cpp should
work.

There is a FindSqlLite3 module here:
http://svn.openstreetmap.org/applications/utils/export/osm2poidb/cmake/Modules/FindSQLite3.cmake

You can use that one instead with a FIND_LIBRARY(  )  clause to avoid
having to add the SQL library by yourself. It can be tricky if you''re not
very familiar with CMake.

Basically what is happening with your project is that you need to specify
where are the headers for your library, and you specify apart the object
compiled code of your library.  I notice that you're a little confused on
how this is done by looking at your ADD_LIBRARY()  [I think you're confused
with what HINTS stands for]

Cheers

On Wed, Mar 4, 2015 at 1:10 PM, Matthieu Estrada <m.estrada at alpi.fr> wrote:

> Hello,
>
>
>
> I have a CMakeLists.txt who contains the following :
>
>
>
> project(sql_sqlite)
>
>
>
> SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /D_USRDLL /DSQL_SQLITE_EXPORTS
> /D_UNICODE /DUNICODE")
>
> SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /GL /Oi /Gy
> /O2 /GR- /Gm- /OPT")
>
> SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX- /ZI /Oy- /Gm
> /EHsc /MDd /GS /Gd ")
>
>
>
>                 set_source_files_properties(../sql_sqlite/stdafx.cpp
> PROPERTIES COMPILE_FLAGS "/Ycstdafx.h")
>
>                 set_source_files_properties(../sql_sqlite/sql_sqlite.cpp
> PROPERTIES COMPILE_FLAGS "/Yustdafx.h")
>
>                 set_source_files_properties(../sql_sqlite/win32/main.cpp
> PROPERTIES COMPILE_FLAGS /Yu"../stdafx.h")
>
>
> set_source_files_properties(../../../external/sqlite/sqlite3.c PROPERTIES
> COMPILE_FLAGS "/Y-")
>
>
>
> add_library(
>
>
>
>                                sql_sqlite
>
>
>
>                                SHARED
>
>
>
>                                 ../sql_sqlite/stdafx.h
>
>                                 ../../../external/sqlite/sqlite3.h
>
>
>
>                                ../sql_sqlite/sql_sqlite.cpp
>
>                                 ../sql_sqlite/stdafx.cpp
>
>                                 ../sql_sqlite/win32/main.cpp
>
>                                 ../../../external/sqlite/sqlite3.c
>
>
>
> )
>
>
>
> I've stdafx.cpp and sql-sqlite.cpp with #include "stdafx.h" (for them
> that's ok), but main.cpp with #include "../stdafx.h" doesn't work. When I
> generate Makefile with the NMake Makefiles generator, and type « nmake »
> I’ve the following issue :
>
>
>
> « fatal error C1083: Cannot open precompiled header file: '../stdafx.pch':
> No such file or directory »
>
>
>
> Why he doesn’t find the stdafx.pch ?
>
> I’ve trying many way to resolve this problem : use backslah, slash, in
> CMakeLists.txt or my main.cpp…. Nothing works.
>
> How I can resolve this problem ? Is there a way to force it or a custom
> command special for precompiled header using relative path ?
>
> Cordials,
>
> *Estrada Matthieu*
>
> Service Informatique / Intégration
>
>
>
> --
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150304/10c0067f/attachment.html>


More information about the CMake mailing list