MantisBT - CMake | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0008725 | CMake | CMake | public | 2009-03-11 18:25 | 2009-10-22 13:06 |
Reporter | Steve Wilson | ||||
Assigned To | Brad King | ||||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Platform | OS | OS Version | |||
Product Version | CMake-2-6 | ||||
Target Version | Fixed in Version | ||||
Summary | 0008725: Add OSX_ARCHITECTURES and OSX_ARCHITECTURES_<CONFIG> to target properties | ||||
Description | Consider the following source tree on OSX: TopDir/ - CMakeLists.txt - src1.c - src2.c Where src1.c is compiled into a 32-bit(i386) binary that links with libExample1.a a non-Universal i386 architecture library. Where src2.c is compiled into a 64-bit(x86_64) binary that links with libExample2.a a non-Universal x86_64 architecture library. libExample1.a and libExample2.a exist outside of the scope of the source tree and cannot be rebuilt to be Universal libraries. Here are the basic entries in CMakeLists.txt: add_executable(src1 src1.c) target_link_libraries(src1 Example1) set_target_properties(src1 PROPERTIES COMPILE_FLAGS "-arch i386" LINK_FLAGS "-arch i386") add_executable(src2 src2.c) target_link_libraries(src2 Example2) set_target_properties(src2 PROPERTIES COMPILE_FLAGS "-arch x86_64" LINK_FLAGS "-arch x86_64" When generating a build system using the 'Unix Makefiles' generator this CMakeLists.txt will correctly build and link src1 and src2 as i386 and x86_64 binaries respectively. When generating a build system using the Xcode generator this CMakeLists.txt will generate an Xcode project that cannot correctly build src2. CMake provides default values for CMAKE_OSX_ARCHITECTURES. When the Xcode generator runs, it will use the default value for CMAKE_OSX_ARCHITECTURES (i386 in this case (assume a Core 2 Duo processor)) and the Xcode project will not have any explicit reference to i386 architectures when it is generated. Xcode will by default use the 'native' architecture for the given machine and automatically append -arch i386 to the compile/link commands for src1 and src2. Given that src2 must be an x86_64 architecture only binary (see dependency on libExample2.a) then src2 cannot link correctly. Explicitly setting CMAKE_OSX_ARCHITECTURES to x86_64 in the CMakeLists.txt file does not solve the problem but rather switches the case to src1 which must be compiled as an i386 architecture only binary. Explicitly setting CMAKE_OSX_ARCHITECTURES to x86_64;i386 violates the requirement that the binaries only have i386 and x86_64 architectures respectively. This behavior makes it impossible to have working Makefile and Xcode build systems generated for this source tree. To put it another way, you cannot generate an Xcode project that contains targets with strict exclusive architecture requirements where those requirements vary by target. In order to correct this deficiency, we need to have a property for targets that allows a target to override the project level CMAKE_OSX_ARCHITECTURES setting. I propose the use of the following property names: OSX_ARCHITECTURES and OSX_ARCHITECTURES_<CONFIG> The CMAKE_OSX_ARCHITECTURES property sets the target binary architecture for targets on OSX. Use CMAKE_OSX_ARCHITECTURES_<CONFIG> to set the binary architectures on a per-configuration basis. <CONFIG> is an upper-case name (ex. CMAKE_OSX_ARCHITECTURES_DEBUG). The upload tarball contains patches that implement this suggestion. The patches were created against the release sources of cmake 2.6.3. I have built and used this patched version on OSX, Linux, Solaris, and Windows without any problems. Let me know if I can provide any other help/comments/etc... Steve | ||||
Steps To Reproduce | |||||
Additional Information | |||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | patches.tgz (2,436) 2009-03-11 18:25 https://public.kitware.com/Bug/file/2119/patches.tgz patches_CVS.tgz (2,475) 2009-10-14 16:58 https://public.kitware.com/Bug/file/2556/patches_CVS.tgz | ||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2009-03-11 18:25 | Steve Wilson | New Issue | |||
2009-03-11 18:25 | Steve Wilson | File Added: patches.tgz | |||
2009-09-18 17:31 | Sean McBride | Note Added: 0017614 | |||
2009-09-18 17:54 | Steve Wilson | Note Added: 0017615 | |||
2009-09-19 10:57 | Brad King | Status | new => assigned | ||
2009-09-19 10:57 | Brad King | Assigned To | => Brad King | ||
2009-09-19 11:15 | Brad King | Note Added: 0017641 | |||
2009-09-21 11:40 | Steve Wilson | Note Added: 0017672 | |||
2009-10-14 16:58 | Steve Wilson | Note Added: 0018070 | |||
2009-10-14 16:58 | Steve Wilson | File Added: patches_CVS.tgz | |||
2009-10-19 16:28 | Brad King | Note Added: 0018114 | |||
2009-10-19 18:07 | Steve Wilson | Note Added: 0018117 | |||
2009-10-19 18:24 | Brad King | Note Added: 0018118 | |||
2009-10-21 13:02 | Brad King | Note Added: 0018146 | |||
2009-10-21 13:03 | Brad King | Note Added: 0018147 | |||
2009-10-21 13:03 | Brad King | Status | assigned => resolved | ||
2009-10-21 13:03 | Brad King | Resolution | open => fixed | ||
2009-10-21 13:03 | Brad King | Status | resolved => feedback | ||
2009-10-21 13:03 | Brad King | Resolution | fixed => reopened | ||
2009-10-22 13:00 | Steve Wilson | Note Added: 0018193 | |||
2009-10-22 13:06 | Brad King | Note Added: 0018194 | |||
2009-10-22 13:06 | Brad King | Status | feedback => closed | ||
2009-10-22 13:06 | Brad King | Resolution | reopened => fixed |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|