diff --git a/example/jit/compile.cpp b/example/jit/compile.cpp index 8ecfa5491..644300a57 100644 --- a/example/jit/compile.cpp +++ b/example/jit/compile.cpp @@ -54,14 +54,17 @@ bool compile(void) // compile std::string compile = ""; int flag; -# ifdef _MSC_VER +# if CPPAD_C_COMPILER_MSVC flag = std::system("cl 1> nul 2> nul"); if( flag == 0 ) compile = "cl /EHs /EHc /c /LD /TC /O2"; -# else +# endif +# if CPPAD_C_COMPILER_GNU flag = std::system("gcc --version > temp"); if( flag == 0 ) compile = "gcc -c -fPIC -O2"; +# endif +# if CPPAD_C_COMPILER_CLANG # ifndef __MINGW32__ // clang: error: unsupported option '-fPIC' for target // 'x86_64-pc-windows-msys' @@ -69,8 +72,8 @@ bool compile(void) if( flag == 0 ) compile = "clang -c -fPIC -O2"; # endif - // # endif + // if( compile == "" ) return ok; // std::cout << "compile = " << compile << "\n"; diff --git a/example/jit/jit.cpp b/example/jit/jit.cpp index 8ebc79d00..516ecd0a5 100644 --- a/example/jit/jit.cpp +++ b/example/jit/jit.cpp @@ -37,7 +37,7 @@ extern bool to_csrc(void); int main(void) { bool ok = true; // -# if CPPAD_GNU_OR_MSVC_C_COMPILER +# if CPPAD_C_COMPILER_GNU || CPPAD_C_COMPILER_MSVC std::string group = "example/jit"; size_t width = 20; CppAD::test_boolofvoid Run(group, width); diff --git a/example/utility/utility.cpp b/example/utility/utility.cpp index 79b324adb..08ec564a9 100644 --- a/example/utility/utility.cpp +++ b/example/utility/utility.cpp @@ -93,8 +93,10 @@ int main(void) Run( vectorBool, "vectorBool" ); // END_SORT_THIS_LINE_MINUS_1 // -# if CPPAD_USE_CPLUSPLUS_2017 && CPPAD_GNU_OR_MSVC_C_COMPILER +# if CPPAD_C_COMPILER_GNU || CPPAD_C_COMPILER_MSVC +# if CPPAD_USE_CPLUSPLUS_2017 Run( dll_lib, "dll_lib" ); +# endif # endif // // check for memory leak diff --git a/include/cppad/CMakeLists.txt b/include/cppad/CMakeLists.txt index 2d4e44602..49dc54c93 100644 --- a/include/cppad/CMakeLists.txt +++ b/include/cppad/CMakeLists.txt @@ -28,13 +28,25 @@ SET(CMAKE_REQUIRED_FLAGS "") SET(CMAKE_REQUIRED_INCLUDES "") SET(CMAKE_REQUIRED_LIBRARIES "") # ----------------------------------------------------------------------------- -# gnu_or_msvc_c_compiler +# cppad_c_compiler_gnu IF( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" ) - SET(gnu_or_msvc_c_compiler 1) -ELSEIF( "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" ) - SET(gnu_or_msvc_c_compiler 1) + SET(cppad_c_compiler_gnu 1) ELSE() - SET(gnu_or_msvc_c_compiler 0) + SET(cppad_c_compiler_gnu 0) +ENDIF() +# +# cppad_c_compiler_msvc +IF( "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" ) + SET(cppad_c_compiler_msvc 1) +ELSE() + SET(cppad_c_compiler_msvc 0) +ENDIF() +# +# cppad_c_compiler_clang +IF( "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" ) + SET(cppad_c_compiler_clang 1) +ELSE() + SET(cppad_c_compiler_clang 0) ENDIF() # ----------------------------------------------------------------------------- # compiler_has_conversion_warn diff --git a/include/cppad/configure.hpp.in b/include/cppad/configure.hpp.in index 7a00417d7..a8b5ecd8b 100644 --- a/include/cppad/configure.hpp.in +++ b/include/cppad/configure.hpp.in @@ -229,10 +229,22 @@ This preprocessor symbol is $code noexcept$$ when C++11 is available and $code NDEBUG$$ is defined. Otherwise it is empty. -$head CPPAD_GNU_OR_MSVC_C_COMPILER$$ -If true, the C complier is $code gcc$$ or $code cl$$. +$head CPPAD_C_COMPILER_GNU$$ +If true, the C complier is $code gcc$$ $srccode%hpp% */ -# define CPPAD_GNU_OR_MSVC_C_COMPILER @gnu_or_msvc_c_compiler@ +# define CPPAD_C_COMPILER_GNU @cppad_c_compiler_gnu@ +/* %$$ + +$head CPPAD_C_COMPILER_MSVC$$ +If true, the C complier is $code cl$$ +$srccode%hpp% */ +# define CPPAD_C_COMPILER_MSVC @cppad_c_compiler_msvc@ +/* %$$ + +$head CPPAD_C_COMPILER_CLANG$$ +If true, the C complier is $code cl$$ +$srccode%hpp% */ +# define CPPAD_C_COMPILER_CLANG @cppad_c_compiler_clang@ /* %$$ $end diff --git a/include/cppad/core/undef.hpp b/include/cppad/core/undef.hpp index f0f6efd2a..f9fd3aa18 100644 --- a/include/cppad/core/undef.hpp +++ b/include/cppad/core/undef.hpp @@ -24,7 +24,9 @@ that are used by the CppAD examples and tests. # undef CPPAD_HASH_TABLE_SIZE used by test_more/optimize.cpp # undef EIGEN_MATRIXBASE_PLUGIN example use of Eigen with CppAD # undef CPPAD_HAS_COLPACK used by speed/cppad/sparse_*.cpp -# undef CPPAD_GNU_OR_MSVC_C_COMPILER used to select dll examples. +# undef CPPAD_C_COMPILER_GNU used to select dll examples. +# undef CPPAD_C_COMPILER_MSVC used to select dll examples. +# undef CPPAD_C_COMPILER_CLANG used to select dll examples. // for conditional testing when implicit conversion is not present diff --git a/omh/example_list.omh b/omh/example_list.omh index d767a50d7..59fd7a0e2 100644 --- a/omh/example_list.omh +++ b/omh/example_list.omh @@ -207,6 +207,7 @@ $rref jac_lu_det.cpp$$ $rref jac_minor_det.cpp$$ $rref jacobian.cpp$$ $rref jit_atomic.cpp$$ +$rref jit_compile.cpp$$ $rref jit_dynamic.cpp$$ $rref jit_get_started.cpp$$ $rref jit_to_csrc.cpp$$ diff --git a/speed/cppad_jit/det_minor.cpp b/speed/cppad_jit/det_minor.cpp index 82c1c9b37..698a88676 100644 --- a/speed/cppad_jit/det_minor.cpp +++ b/speed/cppad_jit/det_minor.cpp @@ -36,7 +36,7 @@ extern std::map global_option; # define DLL_EXT ".so" # endif -# if ! CPPAD_GNU_OR_MSVC_C_COMPILER +# if ! (CPPAD_C_COMPILER_GNU || CPPAD_C_COMPILER_MSVC) bool link_det_minor( const std::string& job , size_t size , @@ -275,7 +275,7 @@ bool link_det_minor( } return true; } -# endif // CPPAD_GNU_OR_MSVC_C_COMPILER +# endif // CPPAD_C_COMPILER_GNU || CPPAD_C_COMPILER_MSVC /* %$$ $end */ diff --git a/test_more/general/general.cpp b/test_more/general/general.cpp index 9f24de82e..303b84272 100644 --- a/test_more/general/general.cpp +++ b/test_more/general/general.cpp @@ -249,7 +249,7 @@ int main(void) Run( tan, "tan" ); Run( to_string, "to_string" ); // END_SORT_THIS_LINE_MINUS_1 -# if CPPAD_GNU_OR_MSVC_C_COMPILER +# if CPPAD_C_COMPILER_GNU || CPPAD_C_COMPILER_MSVC Run( to_csrc, "to_csrc" ); # endif #if CPPAD_HAS_ADOLC