Detect sinf/cosf/sqrtf presence with CMake (instead of relying on __cpluscplus)
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1276 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
0629737fa2
commit
628d9b7a7e
@ -261,6 +261,27 @@ IF (NOT (HAVE_STDINT_H OR HAVE_INTTYPES_H))
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
# Check for sinf/cosf/sqrtf
|
||||||
|
# CHECK_FUNCTION_EXISTS doesn't work because check requires <math.h>
|
||||||
|
#CHECK_FUNCTION_EXISTS(sinf HAVE_SINF)
|
||||||
|
#CHECK_FUNCTION_EXISTS(cosf HAVE_COSF)
|
||||||
|
#CHECK_FUNCTION_EXISTS(sqrtf HAVE_SQRTF)
|
||||||
|
INCLUDE(CheckCSourceCompiles)
|
||||||
|
CHECK_C_SOURCE_COMPILES("
|
||||||
|
#include <math.h>
|
||||||
|
int main(){sinf(0); return 0;}
|
||||||
|
" HAVE_SINF
|
||||||
|
)
|
||||||
|
CHECK_C_SOURCE_COMPILES("
|
||||||
|
#include <math.h>
|
||||||
|
int main(){cosf(0); return 0;}
|
||||||
|
" HAVE_COSF
|
||||||
|
)
|
||||||
|
CHECK_C_SOURCE_COMPILES("
|
||||||
|
#include <math.h>
|
||||||
|
int main(){sqrtf(0); return 0;}
|
||||||
|
" HAVE_SQRTF
|
||||||
|
)
|
||||||
|
|
||||||
# The generated config.h is placed in the project's build directory, just to
|
# The generated config.h is placed in the project's build directory, just to
|
||||||
# ensure that all CMake-generated files are kept away from the main source tree.
|
# ensure that all CMake-generated files are kept away from the main source tree.
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
#cmakedefine HAVE_GETTIMEOFDAY
|
#cmakedefine HAVE_GETTIMEOFDAY
|
||||||
#cmakedefine HAVE_VFPRINTF
|
#cmakedefine HAVE_VFPRINTF
|
||||||
#cmakedefine HAVE_DOPRNT
|
#cmakedefine HAVE_DOPRNT
|
||||||
|
#cmakedefine HAVE_SINF
|
||||||
|
#cmakedefine HAVE_COSF
|
||||||
|
#cmakedefine HAVE_SQRTF
|
||||||
#cmakedefine NEED_XPARSEGEOMETRY_IMPL
|
#cmakedefine NEED_XPARSEGEOMETRY_IMPL
|
||||||
#cmakedefine HAVE_STDINT_H
|
#cmakedefine HAVE_STDINT_H
|
||||||
#cmakedefine HAVE_INTTYPES_H
|
#cmakedefine HAVE_INTTYPES_H
|
||||||
|
@ -34,6 +34,16 @@
|
|||||||
* Need more types of polyhedra? See CPolyhedron in MRPT
|
* Need more types of polyhedra? See CPolyhedron in MRPT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* VC++6 in C mode doesn't have C99's sinf/cos/sqrtf */
|
||||||
|
#ifndef HAVE_SINF
|
||||||
|
#define sinf(x) (float)sin((double)(x))
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_COSF
|
||||||
|
#define cosf(x) (float)cos((double)(x))
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_SQRTF
|
||||||
|
#define sqrtf(x) (float)sqrt((double)(x))
|
||||||
|
#endif
|
||||||
|
|
||||||
/* General functions for drawing geometry
|
/* General functions for drawing geometry
|
||||||
* Solids are drawn by glDrawArrays if composed of triangles, or by
|
* Solids are drawn by glDrawArrays if composed of triangles, or by
|
||||||
@ -829,13 +839,8 @@ static void fghCircleTable(GLfloat **sint, GLfloat **cost, const int n, const GL
|
|||||||
|
|
||||||
for (i=1; i<size; i++)
|
for (i=1; i<size; i++)
|
||||||
{
|
{
|
||||||
#ifdef __cplusplus
|
|
||||||
(*sint)[i] = sinf(angle*i);
|
(*sint)[i] = sinf(angle*i);
|
||||||
(*cost)[i] = cosf(angle*i);
|
(*cost)[i] = cosf(angle*i);
|
||||||
#else
|
|
||||||
(*sint)[i] = (float)sin((double)(angle*i));
|
|
||||||
(*cost)[i] = (float)cos((double)(angle*i));
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -948,13 +953,8 @@ void fghGenerateCone(
|
|||||||
const GLfloat rStep = (GLfloat)base / ( ( stacks > 0 ) ? stacks : 1 );
|
const GLfloat rStep = (GLfloat)base / ( ( stacks > 0 ) ? stacks : 1 );
|
||||||
|
|
||||||
/* Scaling factors for vertex normals */
|
/* Scaling factors for vertex normals */
|
||||||
#ifdef __cplusplus
|
|
||||||
const GLfloat cosn = ( (GLfloat)height / sqrtf( height * height + base * base ));
|
const GLfloat cosn = ( (GLfloat)height / sqrtf( height * height + base * base ));
|
||||||
const GLfloat sinn = ( (GLfloat)base / sqrtf( height * height + base * base ));
|
const GLfloat sinn = ( (GLfloat)base / sqrtf( height * height + base * base ));
|
||||||
#else
|
|
||||||
const GLfloat cosn = ( (GLfloat)height / (GLfloat)sqrt( (double)(height * height + base * base) ));
|
|
||||||
const GLfloat sinn = ( (GLfloat)base / (GLfloat)sqrt( (double)(height * height + base * base) ));
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user