Tom,
A word of caution on the below path that you're starting down, as it's one
we've been down before with the GNU build system. To the extent possible, it
was better for portability to make the build system not aware of the
compiler/linker as much as possible. Our cmake build (predominantly)
implements this same philosophy for the same reasons. We want to avoid
characterizing behavior based on a "name" and instead test features and
behavior individually. For example, instead of:
if(ENABLE_DEBUG)
if(CLANG)
CFLAGS=-g
elseif(HPCC)
CFLAGS=-debug
elseif(MSVC)
CFLAGS=/D
endif
endif
we instead perform a test of that flag, ignorant of the compiler type:
if(ENABLE_DEBUG)
CHECK_C_FLAG(g VARS DEBUG_FLAG)
CHECK_C_FLAG(debug VARS DEBUG_FLAG)
CHECK_C_FLAG(D VARS DEBUG_FLAG)
endif
The latter is more future-proof to changes in a compiler and is more likely to
support some compiler we've never tested. If we ever encounter a false
positive, the tests are adjusted. It's the same philosophy we use in the
source code, to test for features instead of making an assumption about what
constitutes a platform. The hacking file talks about this briefly in the build
system section under style and conventions.
With the below commit, the first mismatch test is compiler agnostic and
certainly not a problem if you encountered a case where a mismatch was
incompatible. I'd be interested in knowing what you ran into there. I've
compiled with gcc for C and clang for C++ and been able to link the two
together in the past, but can imagine there might be some incompatibility with
two compilers that don't try as hard to be work with each other.
Unless I've completely misunderstood the intent, the variables you set up at
the bottom would indicate intent to introduce "name-specific" assumptions like
the aforementioned pattern. Right now, as far as I know, we currently do this
for MSVC so it's not surprising that you might think of that route. However,
that is only because it's just SO terribly slow in some compilation contexts we
have no control over (nearly an hour to run cmake) and having it test all of
the GCC-style flags would currently make it even slower (maybe two+ hours). In
general, we do stick to testing features, though, and need to do an even better
job of testing for how they work. I think your compliance flags actually help
in that regard considerably if only because we've had to clean up
cflag/cppflag/ldflag management as a result. :)
Cheers!
Sean
On Oct 7, 2013, at 9:09 AM, [email protected] wrote:
> Revision: 58134
> http://sourceforge.net/p/brlcad/code/58134
> Author: tbrowder2
> Date: 2013-10-07 13:09:48 +0000 (Mon, 07 Oct 2013)
> Log Message:
> -----------
> add code for compiler ID; shorten length of associated compiler vars
>
> Modified Paths:
> --------------
> brlcad/trunk/CMakeLists.txt
> brlcad/trunk/misc/CMake/BRLCAD_Summary.cmake
>
> Modified: brlcad/trunk/CMakeLists.txt
> ===================================================================
> --- brlcad/trunk/CMakeLists.txt 2013-10-07 11:08:02 UTC (rev 58133)
> +++ brlcad/trunk/CMakeLists.txt 2013-10-07 13:09:48 UTC (rev 58134)
> @@ -1476,11 +1476,32 @@
>
> # Non-gcc compilers may need their own options--report details.
> set(C_ID "${CMAKE_C_COMPILER_ID}")
> -set(C_VERSION "${CMAKE_C_COMPILER_VERSION}")
> +set(C_VER "${CMAKE_C_COMPILER_VERSION}")
> set(CXX_ID "${CMAKE_CXX_COMPILER_ID}")
> -set(CXX_VERSION "${CMAKE_CXX_COMPILER_VERSION}")
> +set(CXX_VER "${CMAKE_CXX_COMPILER_VERSION}")
> +# error to have mismatching C/C++ compilers
> +if(NOT "${C_ID}" STREQUAL "${CXX_ID}")
> + message(FATAL_ERROR "C/C++ compiler mismatch: C = '${C_ID}'; C++ =
> '${CXX_ID}'")
> +else()
> + string(TOUPPER "${C_ID}" "${C_ID}")
> + string(TOUPPER "${CXX_ID}" "${CXX_ID}")
> + string(TOUPPER "${C_VER}" "${C_VER}")
> + string(TOUPPER "${CXX_VER}" "${CXX_VER}")
> +endif()
> +# Need flags for various compiler settings and checks later. (Add
> +# more compiler flags as they are needed.)
> +set(INTEL OFF)
> +set(CLANG OFF)
> +set(GNU OFF)
> +if("${C_ID}" STREQUAL "INTEL")
> + set(INTEL ON)
> +elseif("${C_ID}" STREQUAL "CLANG")
> + set(CLANG ON)
> +elseif("${C_ID}" STREQUAL "GNU")
> + set(GNU ON)
> +endif()
> +message(FATAL_ERROR "debug: C = '${C_ID}'; C++ = '${CXX_ID}'")
>
> -
> # *******************************************************************
> if(NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt.prev)
> message("***********************************************************")
>
> Modified: brlcad/trunk/misc/CMake/BRLCAD_Summary.cmake
> ===================================================================
> --- brlcad/trunk/misc/CMake/BRLCAD_Summary.cmake 2013-10-07 11:08:02 UTC
> (rev 58133)
> +++ brlcad/trunk/misc/CMake/BRLCAD_Summary.cmake 2013-10-07 13:09:48 UTC
> (rev 58134)
> @@ -247,9 +247,9 @@
> set(ENABLE_STRICT_COMPILER_STANDARD_COMPLIANCE_LABEL "Build with strict ISO C
> compliance checking ")
> set(ENABLE_POSIX_COMPLIANCE_LABEL "Build with strict POSIX compliance
> checking ")
> set(C_ID_LABEL "C compiler ID ")
> -set(C_VERSION_LABEL "C compiler version ")
> +set(C_VER_LABEL "C compiler version ")
> set(CXX_ID_LABEL "C++ compiler ID ")
> -set(CXX_VERSION_LABEL "C++ compiler version")
> +set(CXX_VER_LABEL "C++ compiler version")
>
> # Make sets to use for iteration over all report items
> set(BUILD_REPORT_ITEMS
> @@ -267,7 +267,7 @@
> BRLCAD_ENABLE_COMPILER_WARNINGS BRLCAD_ENABLE_VERBOSE_PROGRESS
> BRLCAD_INSTALL_EXAMPLE_GEOMETRY BRLCAD_DOCBOOK_BUILD
> ENABLE_STRICT_COMPILER_STANDARD_COMPLIANCE ENABLE_POSIX_COMPLIANCE
> - C_ID C_VERSION CXX_ID CXX_VERSION
> + C_ID C_VER CXX_ID CXX_VER
> )
>
> # Construct list of all items
>
> This was sent by the SourceForge.net collaborative development platform, the
> world's largest Open Source development site.
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
> _______________________________________________
> BRL-CAD Source Commits mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/brlcad-commits
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-devel