Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling Custom QMake Function defined in Parent .pro file

Tags:

qt

qmake

I have defined a simple qmake function as the one below:

defineReplace(generateBoilerPlate){        
     message("Generating boiler plate code...")
}

My project is arranged in the following hierachial manner:

ProjectDir
    ProjectName.pro
    ModuleName1SubDir
         ModuleName1.pro
    ModuleName2SubDir
         ModuleName2.pro

I have defined the aforementioned custom function in ProjectName.pro

I am able to successfully call this function within ProjectName.pro using:

out = $$generateBoilerPlate()

However, I want to be able to call the custom function 'generateBoilerPlate' from within the .pro files inside the module subdirectories (i.e. in the example above, I want to call the function in ModuleName1.pro AND ModuleName2.pro).

When I try and invoke the function in the submodules' .pro files, I get the following error:

 'generateBoilerPlate' is not a recognized replace function.

Can someone please tell me how to achieve what I want?

like image 702
balajeerc Avatar asked Oct 06 '14 07:10

balajeerc


1 Answers

As possible solution, you can define your functions in separate .pri file and include it in your .pro files whenever you need your to use your functions.

like image 195
Max Go Avatar answered Oct 04 '22 21:10

Max Go