0

I'm current making a installer for a large project, where it requires to get the most up-to-date tables from database. Till now the Database dump was done manually, now i want it to be done automatically when i generate the installer. Since there is already a script doing the dump process, i am wondering if it is possible to tell CPack (or CMake) to run this script first before generating the installer? For instance, there is a rule in the CMakeList:

    install(
            FILES "../db/structures.sql"
            DESTINATION ${INSTALL_DB} 
            CONFIGURATIONS Release
            RENAME "create.sql"
    )

The Sql-Dump file "structures.sql" can automatically being created using another script called "make_db_dump.pl" (So in the command line it should be called using "perl make_db_dump.pl"). And i want the make_db_dump.pl to be automatically called and file generated before generating the installer. Is that possible?

For the environment: im using VS 2019 together with CMake under windows.

And the workflow is:CMake -> VS Project -> generating installer

4
  • 1
    Just create the file structures.sql as part of your build process (using add_custom_target/add_custom_command). So the file will exist at the time the installer packs it. Note, that installation process is just "take this file and put it into the installation directory". Creation of the file intended to be installed is responsibility of the build process.
    – Tsyvarev
    Commented Mar 22, 2021 at 10:10
  • @Tsyvarev there is in fact no build process here for this project, it's actually simply packing all database related files together and some other configurations. Is it still possible to do such things? (sry, im new to CMake)
    – tyker1
    Commented Mar 22, 2021 at 10:21
  • 1
    Creation of any file you want to deliver to the user is a build process. Even if this creation is "simply packing all database related files together and some other configurations". Installation (or packaging) works with all needed files already existing.
    – Tsyvarev
    Commented Mar 22, 2021 at 10:35
  • @Tsyvarev got it, tyvm :)
    – tyker1
    Commented Mar 22, 2021 at 10:41

1 Answer 1

1

In NSIS you can execute external commands from inside the compiler with !system:

!system '"c:\stuff\app.exe" -foo -bar' 
3
  • but how to do it with CMake? or CPack? due to the requirements, i cannot create my own NSIS script for generating the installer, it must be generated by VS2019 and Cmake (CPack)
    – tyker1
    Commented Mar 22, 2021 at 12:36
  • CPACK_NSIS_EXTRA_INSTALL_COMMANDS
    – Anders
    Commented Mar 22, 2021 at 16:54
  • got it, both your solution and the one from Tsyvarev works fine, tyvm
    – tyker1
    Commented Mar 23, 2021 at 8:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.