Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to share custom build step between Win and Osx ?
Forum Updated to NodeBB v4.3 + New Features

How to share custom build step between Win and Osx ?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 1.9k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Manfred
    wrote on 28 Nov 2016, 10:45 last edited by
    #1

    Hello everybody

    I need your help please !
    I'm trying to create a Qt project that would build a dynamic library on window and a static one on osx from the same code.
    Therefore I need different custom build steps for each platform that copy some dependent files for deployment etc.

    Is there a way to manage that directly in the .pro file instead of having the custom steps in the .pro.user file?

    Many thanks in advance
    regards
    Manfred

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rondog
      wrote on 28 Nov 2016, 18:37 last edited by
      #2

      If you add something like this to your project file of your library it should work:

      TEMPLATE = 			lib
      CONFIG += 			staticlib
      
      win32 { 
      CONFIG -= 			staticlib
      CONFIG +=			dll
      }
      

      When the library is compiled on OS X (or anything other than Windows for that matter) then you will end up with a static library. When compiled on Windows you will end up with a dynamic library (DLL).

      There is nothing you need to change in the project file for the application that uses the library. You likely need the INCLUDEPATH and LIBS entries regardless if this is static or dynamic but no other changes should be needed to the application that uses the library.

      1 Reply Last reply
      2
      • M Offline
        M Offline
        Manfred
        wrote on 29 Nov 2016, 18:37 last edited by
        #3

        Hi Rondog,
        thanks for your reply.
        Yes this is what I already do but I need to deploy different files for each platform that are currently managed by custom build steps.

        For example, the windows DLL should ship with a DEF file that is needed by clients that use VisualStudio

        The problem is that these custom build steps are saved in the .pro.user file and are specific for each developer.
        I'd like to share these custom build steps among my team and still being able to build for different platforms.

        Any ideas?

        regards
        Manfred

        M 1 Reply Last reply 29 Nov 2016, 18:52
        0
        • M Manfred
          29 Nov 2016, 18:37

          Hi Rondog,
          thanks for your reply.
          Yes this is what I already do but I need to deploy different files for each platform that are currently managed by custom build steps.

          For example, the windows DLL should ship with a DEF file that is needed by clients that use VisualStudio

          The problem is that these custom build steps are saved in the .pro.user file and are specific for each developer.
          I'd like to share these custom build steps among my team and still being able to build for different platforms.

          Any ideas?

          regards
          Manfred

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 29 Nov 2016, 18:52 last edited by
          #4

          @Manfred said in How to share custom build step between Win and Osx ?:

          I'd like to share these custom build steps

          How often would they be updated?
          it is pretty easy to grab section and
          simply paste into other .user file.
          If many, it always works pretty good to simply use the code revision tool to merge it into
          an existing .user file. Its xml so pretty structured. You could even write tool do it if really many.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            joeQ
            wrote on 30 Nov 2016, 02:50 last edited by joeQ 12 Jan 2016, 03:59
            #5

            I think you use the like this steps.

            Build Steps

            qmake: qmake.exe demo.pro -r -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
            Make: mingw32-make.exe in E:\Work\App\demo\build-demo-Desktop_Qt_5_7_0_MinGW_32bit-Debug
            Custom Process Step: xcopy /Y/D .\_LIB\\Lib\Win32\Debug\*.dll ..\build-demo-Desktop_Qt_5_
            

            But the Custom Process Step is in .user.pro file. And we can not commit it to Git and share to other one.

            And How to do it ?

            From the case, we use the perl Scripting language(you can do other language).

            Share my perl code for you wish to help you.

            my $OS_type = $^O;  # maybe "MSWin32" for Win32 or "darwin" for MacOSX or "linux" for ubuntu
            
            if($OS_type =~ /MSWin32/){
            	$Des_D = '..\build-demo-Desktop_Qt_5_7_0_MinGW_32bit-Debug\debug';
            	$Des_R = '..\build-demo-Desktop_Qt_5_7_0_MinGW_32bit-Release\release';	
            	((-d $Des_D) || (-d $Des_R)) || die;	
            	$demoDllPath = '.\_LIB\libs\Lib\Win32'; (-d $demoDllPath) || die;
            		
            	# copy lib files	
            	if(-d $Des_D) {			
            		system("xcopy /Y/D $demoDllPath\\Debug\\*.dll $Des_D\\");
            	}
            	if(-d $Des_R) {			
            		system("xcopy /Y/D $demoDllPath\\Release\\*.dll $Des_R\\");
            	}	
            } 
            elsif($OS_type =~ /darwin/){ # MAC OSX
            	$Des_D = '../build-demo-Desktop_Qt_5_7_0_clang_64bit-Debug';	             
            	$Des_R = '../build-demo-Desktop_Qt_5_7_0_clang_64bit-Release';
            	((-d $Des_D) || (-d $Des_R)) || die;
            	$demoDylibPath = './_LIB/libs/Lib/OSX'; (-d $demoDylibPath) || die;
            		
            	# copy lib files : 
            	if(-d $Des_D) {			
            		system("cp -f $demoDylibPath/Debug/libDemoApp.dylib $AppPath/libDemoApp.1.dylib");		
            	}
            	if(-d $Des_R) {	
            		system("cp -f $demoDylibPath/Release/libDemoApp.dylib $AppPath/libDemoApp.1.dylib");
            	}			
            		
             
            else { die(">$OS_type<\n"); }
            
             system("pause");
            

            And then , You just add bulid step to your user.pro file. oh, Don't forget your computer must can run the perl code or some other scripting code.

            Custom Process Step: perl build_perl_script.pl
            

            Just do it!

            M 1 Reply Last reply 30 Nov 2016, 14:57
            1
            • J joeQ
              30 Nov 2016, 02:50

              I think you use the like this steps.

              Build Steps

              qmake: qmake.exe demo.pro -r -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
              Make: mingw32-make.exe in E:\Work\App\demo\build-demo-Desktop_Qt_5_7_0_MinGW_32bit-Debug
              Custom Process Step: xcopy /Y/D .\_LIB\\Lib\Win32\Debug\*.dll ..\build-demo-Desktop_Qt_5_
              

              But the Custom Process Step is in .user.pro file. And we can not commit it to Git and share to other one.

              And How to do it ?

              From the case, we use the perl Scripting language(you can do other language).

              Share my perl code for you wish to help you.

              my $OS_type = $^O;  # maybe "MSWin32" for Win32 or "darwin" for MacOSX or "linux" for ubuntu
              
              if($OS_type =~ /MSWin32/){
              	$Des_D = '..\build-demo-Desktop_Qt_5_7_0_MinGW_32bit-Debug\debug';
              	$Des_R = '..\build-demo-Desktop_Qt_5_7_0_MinGW_32bit-Release\release';	
              	((-d $Des_D) || (-d $Des_R)) || die;	
              	$demoDllPath = '.\_LIB\libs\Lib\Win32'; (-d $demoDllPath) || die;
              		
              	# copy lib files	
              	if(-d $Des_D) {			
              		system("xcopy /Y/D $demoDllPath\\Debug\\*.dll $Des_D\\");
              	}
              	if(-d $Des_R) {			
              		system("xcopy /Y/D $demoDllPath\\Release\\*.dll $Des_R\\");
              	}	
              } 
              elsif($OS_type =~ /darwin/){ # MAC OSX
              	$Des_D = '../build-demo-Desktop_Qt_5_7_0_clang_64bit-Debug';	             
              	$Des_R = '../build-demo-Desktop_Qt_5_7_0_clang_64bit-Release';
              	((-d $Des_D) || (-d $Des_R)) || die;
              	$demoDylibPath = './_LIB/libs/Lib/OSX'; (-d $demoDylibPath) || die;
              		
              	# copy lib files : 
              	if(-d $Des_D) {			
              		system("cp -f $demoDylibPath/Debug/libDemoApp.dylib $AppPath/libDemoApp.1.dylib");		
              	}
              	if(-d $Des_R) {	
              		system("cp -f $demoDylibPath/Release/libDemoApp.dylib $AppPath/libDemoApp.1.dylib");
              	}			
              		
               
              else { die(">$OS_type<\n"); }
              
               system("pause");
              

              And then , You just add bulid step to your user.pro file. oh, Don't forget your computer must can run the perl code or some other scripting code.

              Custom Process Step: perl build_perl_script.pl
              
              M Offline
              M Offline
              Manfred
              wrote on 30 Nov 2016, 14:57 last edited by Manfred
              #6

              Hi and thank you both for your comments!

              I finally opted for the script solution as I find it to be the most flexible one.
              I basically launch a script from my pro file, depending on the platform

              win32{
                  message( "------------BUILDING FOR WINDOWS32 -----------");
                  DEFINES += LIB_WIN
                  QMAKE_CXXFLAGS += -shared
                  . . .
                  # Post link steps 
                  QMAKE_POST_LINK = $$PWD/win_post.bat $$PWD $$OUT_PWD 
              }
              iphoneos {
                  message( "-------------BUILDING FOR IOS --------------");
              
                  DEFINES += LIB_IOS
                  QT -= gui
                  Qt =+ core
                  TARGET = . . .
                  TEMPLATE = lib
                  CONFIG -= dll
                  CONFIG += staticlib
                  . . . 
              
                  QMAKE_POST_LINK = $$PWD/ios_post.sh $$PWD $$OUT_PWD 
              }
              
              

              I consider the subject SOLVED!

              Thanks again and have a nice day!
              best regards
              Manfred

              J 1 Reply Last reply 1 Dec 2016, 04:01
              2
              • M Manfred
                30 Nov 2016, 14:57

                Hi and thank you both for your comments!

                I finally opted for the script solution as I find it to be the most flexible one.
                I basically launch a script from my pro file, depending on the platform

                win32{
                    message( "------------BUILDING FOR WINDOWS32 -----------");
                    DEFINES += LIB_WIN
                    QMAKE_CXXFLAGS += -shared
                    . . .
                    # Post link steps 
                    QMAKE_POST_LINK = $$PWD/win_post.bat $$PWD $$OUT_PWD 
                }
                iphoneos {
                    message( "-------------BUILDING FOR IOS --------------");
                
                    DEFINES += LIB_IOS
                    QT -= gui
                    Qt =+ core
                    TARGET = . . .
                    TEMPLATE = lib
                    CONFIG -= dll
                    CONFIG += staticlib
                    . . . 
                
                    QMAKE_POST_LINK = $$PWD/ios_post.sh $$PWD $$OUT_PWD 
                }
                
                

                I consider the subject SOLVED!

                Thanks again and have a nice day!
                best regards
                Manfred

                J Offline
                J Offline
                joeQ
                wrote on 1 Dec 2016, 04:01 last edited by
                #7

                @Manfred Very Good!

                Just do it!

                1 Reply Last reply
                0

                4/7

                29 Nov 2016, 18:52

                • Login

                • Login or register to search.
                4 out of 7
                • First post
                  4/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved