Solution-wide #define

前端 未结 11 2302
予麋鹿
予麋鹿 2020-12-05 09:29

Is there a way to globally declare a #define?

Like I want to have a file that has for instance,

#define MONO

and I want all source-

11条回答
  •  盖世英雄少女心
    2020-12-05 09:37

    I know solution for C# projects (I don't tested it for any other projects)

    For example you have:

    Project1\
    Project2\
    Solution1\Solution1.sln
    Solution2\Solution2.sln
    

    Create SolutionDefines.targets file in solution directory

    Project1\
    Project2\
    Solution1\Solution1.sln
    Solution1\SolutionDefines.targets
    Solution2\Solution2.sln
    Solution2\SolutionDefines.targets
    Solution3\Solution2.sln
    Solution3\|no target file|
    

    in each project file add:

    
    

    In Solution1\SolutionDefines.targets add:

    
        
            $(DefineConstants);TRACING_BUILD
        
    
    

    In Solution2\SolutionDefines.targets add:

    
        
            $(DefineConstants);ANOTHER_DEFINE
        
    
    

    In this case you have:

    For Solution1 - all projects have TRACING_BUILD define added

    For Solution2 - all projects have ANOTHER_DEFINE define added

    For Solution3 - all projects - no defines added

    In this approach you must store all solutions with solution wide defines in separate directories

提交回复
热议问题