![]() ![]() To detect operating system, generator, compiler, etc., is another story, but you can use the architecture check nested inside various other if-statement, e.g. This is only the target architecture (i.e. It will either be x86 (32 bit) or amd64 (64 bit). If("x86" IN_LIST CMAKE_CPU_ARCHITECTURES) # I am targeting 32-bit x86. if("amd64" IN_LIST CMAKE_CPU_ARCHITECTURES) # I am targeting 64-bit x86. You should check to see if the one you want is in this list. This variable is a list (because XCode project files can target multiple architectures at once). Then you will have a variable CMAKE_CPU_ARCHITECTURES in the folder where you included() this script, and all subfolders. Put it in your CMake modules folder and include() it at least once in your project (it has an include guard so multiple inclusions are okay). ![]() It works by using the preprocessor to communicate back to the CMake script. This script is designed to handle them all (in theory), and give CMake much higher detection fidelity. There are many different C compilers and they give many inconsistent answers back. I then found Jake Petroules' script and continued to assimilate bits and pieces from multiple sources scoured off the Internet to detect target architectures in general using the C compiler. Here is a script I originally started writing to detect whether a target was x86 (32-bit x86) or amd64 (64-bit x86). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |