Browse Source

enable 32bit builds on 64-bit hosts

Grant Limberg 5 years ago
parent
commit
3268effabf
3 changed files with 16 additions and 6 deletions
  1. 5 0
      CMakeLists.txt
  2. 6 1
      Jenkinsfile
  3. 5 5
      Makefile

+ 5 - 0
CMakeLists.txt

@@ -104,6 +104,11 @@ else(WIN32)
 			$<$<CONFIG:RELWITHDEBINFO>:-fPIE>
 			$<$<CONFIG:RELWITHDEBINFO>:-g>
 		)
+		option(BUILD_32BIT "Force building as 32-bit binary")
+		if(BUILD_32BIT)
+			set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
+			set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")
+		endif(BUILD_32BIT)
 	endif(APPLE)
 endif(WIN32)
 

+ 6 - 1
Jenkinsfile

@@ -282,9 +282,14 @@ def buildDebianNative() {
                 }
                 def runtime = docker.image("ztbuild/${distro}-${arch}:latest")
                 runtime.inside {
+                    def cmakeFlags = ""
+                    if (arch == "i386") {
+                        cmakeFlags = 'CMAKE_ARGS="-DBUILD_32BIT=1"'
+                    }
+                   
                     sh 'whoami'
                     dir("build") {
-                        sh 'make -j4'
+                        sh "${cmakeFlags} make -j4"
                     }
                     // sh "mkdir -p ${distro}"
                     // sh "mv *.deb ${distro}"

+ 5 - 5
Makefile

@@ -7,19 +7,19 @@ all:	setup
 	cd ${BUILDDIR} && $(MAKE) -j$(shell getconf _NPROCESSORS_ONLN)
 
 setup:
-	mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Release
+	mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Release ${CMAKE_ARGS}
 
 setup-debug:
-	mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Debug
+	mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Debug ${CMAKE_ARGS}
 
 debug:
-	mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Debug  && $(MAKE)
+	mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Debug ${CMAKE_ARGS} && $(MAKE)
 
 central-controller:
-	mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_CENTRAL_CONTROLLER=1 && $(MAKE) -j4
+	mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_CENTRAL_CONTROLLER=1 ${CMAKE_ARGS} && $(MAKE) -j4
 
 central-controller-debug:
-	mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_CENTRAL_CONTROLLER=1 && $(MAKE) -j4
+	mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_CENTRAL_CONTROLLER=1 ${CMAKE_ARGS}  && $(MAKE) -j4
 
 central-controller-docker:
 	docker build -t registry.zerotier.com/zerotier-central/ztcentral-controller:${TIMESTAMP} -f controller/central-docker/Dockerfile .