Generated header dependency problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Generated header dependency problem

Rob Boehne

All,

 

I have some files that get “sed” run on them, and that output is written to a file with the suffix “nps”

These files are #included by a C++ source file listed as a source for a library in the same CMakeLists.txt

 

The documentation suggests that the dependency the .cpp file has on the generated include files will be handled automatically – but I don’t see any reference to them in the generate Makefile (except in CXX.includecache)

 

Here is the section of CMakeLists.txt that generates the files:

 

    set(SED_CMD  "sed -e 's/\"/\\\\\"/g'  -e 's/\\(.*\\)/\"\\1\\\\n\"/'" )

 

    FOREACH( PS_FILE

            macrmenc.ps

            winenc.ps

        )

        string(REGEX REPLACE "^(.+)\.ps$" "\\1\.nps" NPS_FILE  ${PS_FILE} )

        set(PS_PATH "../../../Source/PDCore/ProcSet/${PS_FILE}")

        add_custom_command(OUTPUT ${NPS_FILE}

                           COMMAND  ${SED_CMD}

                           MAIN_DEPENDENCY ${PS_PATH}

                           VERBATIM )

    ENDFOREACH()

 

My question is, How do I get the source file that includes these to cause them to be generated?

In other words, why doesn’t the C++ scanner see that a file named “winenc.nps” is included but is not present and generate it from “winenc.ps” ?

 

I’m using CMake 3.12.1 and the Makefile generator, and the symptom is that everything builds up to the point where the CPP file that includes “winenc.nps” is compiled, and that fails with:

    error: winenc.nps: No such file or directory

 

TIA,

 

Rob

 

cid:image002.png@01D3D0E3.DCFE6710

Rob Boehne

Senior Software Architect | Datalogics, Inc.

<a href="tel:(312)%20853-8351">+1.312.853.8351 | [hidden email]

datalogics.com | blogs.datalogics.com

Connect with us: Facebook | Twitter | LinkedIn | YouTube

 

 


--

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:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: [SPAM] Generated header dependency problem

Rob Boehne

I found “add_file_dependencies” and now I’ve got this working

 

    include(AddFileDependencies)

 

    FOREACH( PS_FILE

            macrmenc.ps

            winenc.ps

        )

        string(REGEX REPLACE "^(.+)\.ps$" "\\1\.nps" NPS_FILE  ${PS_FILE} )

        set(PS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../Source/PDCore/ProcSet/${PS_FILE}")

        add_custom_command(OUTPUT ${NPS_FILE}

                           COMMAND sed -f ${CMAKE_SOURCE_DIR}/pdfl/PDF/Build/Toolkit/dl-cmake/quotit.sed ${PS_PATH} > ${CMAKE_CURRENT_BINARY_DIR}/${NPS_FILE}

                           MAIN_DEPENDENCY ${PS_PATH}

                           COMMENT "Generating ${NPS_FILE} from ${PS_FILE}"

                           VERBATIM )

        add_file_dependencies(../../../Source/PDCore/ProcSet/Unix/ProcSetsUnix.cpp  ${CMAKE_CURRENT_BINARY_DIR}/${NPS_FILE})

    ENDFOREACH()

 

   

 

From: CMake <[hidden email]> on behalf of Rob Boehne <[hidden email]>
Date: Thursday, October 18, 2018 at 1:29 PM
To: "[hidden email]" <[hidden email]>
Subject: [SPAM] [CMake] Generated header dependency problem

 

All,

 

I have some files that get “sed” run on them, and that output is written to a file with the suffix “nps”

These files are #included by a C++ source file listed as a source for a library in the same CMakeLists.txt

 

The documentation suggests that the dependency the .cpp file has on the generated include files will be handled automatically – but I don’t see any reference to them in the generate Makefile (except in CXX.includecache)

 

Here is the section of CMakeLists.txt that generates the files:

 

    set(SED_CMD  "sed -e 's/\"/\\\\\"/g'  -e 's/\\(.*\\)/\"\\1\\\\n\"/'" )

 

    FOREACH( PS_FILE

            macrmenc.ps

            winenc.ps

        )

        string(REGEX REPLACE "^(.+)\.ps$" "\\1\.nps" NPS_FILE  ${PS_FILE} )

        set(PS_PATH "../../../Source/PDCore/ProcSet/${PS_FILE}")

        add_custom_command(OUTPUT ${NPS_FILE}

                           COMMAND  ${SED_CMD}

                           MAIN_DEPENDENCY ${PS_PATH}

                           VERBATIM )

    ENDFOREACH()

 

My question is, How do I get the source file that includes these to cause them to be generated?

In other words, why doesn’t the C++ scanner see that a file named “winenc.nps” is included but is not present and generate it from “winenc.ps” ?

 

I’m using CMake 3.12.1 and the Makefile generator, and the symptom is that everything builds up to the point where the CPP file that includes “winenc.nps” is compiled, and that fails with:

    error: winenc.nps: No such file or directory

 

TIA,

 

Rob

 

cid:image002.png@01D3D0E3.DCFE6710

Rob Boehne

Senior Software Architect | Datalogics, Inc.

<a href="tel:(312)%20853-8351">+1.312.853.8351 | [hidden email]

datalogics.com | blogs.datalogics.com

Connect with us: Facebook | Twitter | LinkedIn | YouTube

 

 


--

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:
https://cmake.org/mailman/listinfo/cmake