diff --git a/CMakeLists.txt b/CMakeLists.txt index 496712d5..aa07592d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,9 @@ include(TestBigEndian) find_package(PythonInterp 3.6) project(graphite2) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) -if (NOT CMAKE_BUILD_TYPE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE Release) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE) + message(STATUS "CMAKE_BUILD_TYPE is not specified, default to Release. Note that this is only relevant for single-configuration generators (such as Makefile Generators and Ninja).") endif() option(BUILD_SHARED_LIBS "Make library a shared library instead of static" ON) @@ -82,16 +83,20 @@ if (BUILD_SHARED_LIBS) endif() add_subdirectory(src) -add_subdirectory(tests) +if (NOT GRAPHITE2_NFILEFACE) + # tests cannot be built with GRAPHITE2_NFILEFACE + add_subdirectory(tests) +endif() add_subdirectory(doc) if (NOT GRAPHITE2_NFILEFACE) add_subdirectory(gr2fonttest) endif() set(version 3.0.1) +set(prefix ${CMAKE_INSTALL_PREFIX}) set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) set(includedir ${CMAKE_INSTALL_PREFIX}/include) -configure_file(graphite2.pc.in graphite2.pc) +configure_file(graphite2.pc.in graphite2.pc @ONLY) install(FILES ${PROJECT_BINARY_DIR}/graphite2.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig) diff --git a/graphite2.pc.in b/graphite2.pc.in index a4f19b39..bfbd9fc2 100644 --- a/graphite2.pc.in +++ b/graphite2.pc.in @@ -1,7 +1,11 @@ +prefix=@prefix@ +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include Name: Graphite2 Description: Font rendering engine for Complex Scripts -Version: ${version} +Version: @version@ Libs: -L${libdir} -lgraphite2 Cflags: -I${includedir} diff --git a/python/graphite2/__init__.py b/python/graphite2/__init__.py index cddf6240..0d5e8003 100644 --- a/python/graphite2/__init__.py +++ b/python/graphite2/__init__.py @@ -39,9 +39,9 @@ # find wheel's library wheel = os.path.dirname(__file__) if os.name == 'nt': - libpath = os.path.join(wheel, 'bin', 'graphite2.dll') + libpath = os.path.join(wheel, '..', 'bin', 'graphite2.dll') else: - libpath = os.path.join(wheel, 'lib', 'libgraphite2.so') + libpath = os.path.join(wheel, '..', 'lib', 'libgraphite2.so') gr2 = ctypes.cdll.LoadLibrary(libpath) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b6ac26bf..d1293633 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -102,12 +102,12 @@ set_target_properties(graphite2 PROPERTIES PUBLIC_HEADER "${GRAPHITE_HEADERS}" LT_VERSION_REVISION ${GRAPHITE_API_REVISION} LT_VERSION_AGE ${GRAPHITE_API_AGE}) -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +if (${CMAKE_SYSTEM_NAME} STREQUAL ".*Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL ".*GNU") set_target_properties(graphite2 PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wno-unknown-pragmas -Wendif-labels -Wshadow -Wctor-dtor-privacy -Wnon-virtual-dtor -fno-rtti -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden" LINK_FLAGS "-nodefaultlibs ${GRAPHITE_LINK_FLAGS}" LINKER_LANGUAGE C) - if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86|i.86") + if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86|i.86|amd64") add_definitions(-mfpmath=sse -msse2) endif() if (CMAKE_COMPILER_IS_GNUCXX) @@ -131,7 +131,9 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") nolib_test(stdc++ $) endif () set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") - CREATE_LIBTOOL_FILE(graphite2 "/lib${LIB_SUFFIX}") + if (BUILD_SHARED_LIBS) + CREATE_LIBTOOL_FILE(graphite2 "/lib${LIB_SUFFIX}") + endif() endif() if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") @@ -139,21 +141,30 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") COMPILE_FLAGS "-Wall -Wextra -Wno-unknown-pragmas -Wimplicit-fallthrough -Wendif-labels -Wshadow -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -fno-rtti -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden" LINK_FLAGS "-nodefaultlibs" LINKER_LANGUAGE C) - if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86|i.86") + if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86|i.86|amd64") add_definitions(-mfpmath=sse -msse2) endif() target_link_libraries(graphite2 c) include(Graphite) - nolib_test(stdc++ $) + if (BUILD_SHARED_LIBS) + nolib_test(stdc++ $) + endif() set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") - CREATE_LIBTOOL_FILE(graphite2 "/lib${LIB_SUFFIX}") + if (BUILD_SHARED_LIBS) + CREATE_LIBTOOL_FILE(graphite2 "/lib${LIB_SUFFIX}") + endif() endif() if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - set_target_properties(graphite2 PROPERTIES - COMPILE_DEFINITIONS "_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;UNICODE;GRAPHITE2_EXPORTING") + if (BUILD_SHARED_LIBS) + set_target_properties(graphite2 PROPERTIES + COMPILE_DEFINITIONS "_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;UNICODE;GRAPHITE2_EXPORTING") + else() + set_target_properties(graphite2 PROPERTIES + COMPILE_DEFINITIONS "_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;UNICODE;GRAPHITE2_STATIC") + endif() endif() install(TARGETS graphite2 EXPORT graphite2 LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX} PUBLIC_HEADER DESTINATION include/graphite2 RUNTIME DESTINATION bin) -install(EXPORT graphite2 DESTINATION share/graphite2 NAMESPACE gr2_) +install(EXPORT graphite2 DESTINATION lib${LIB_SUFFIX}/graphite2 NAMESPACE gr2_) diff --git a/src/inc/Machine.h b/src/inc/Machine.h index b23819fb..0f75ae89 100644 --- a/src/inc/Machine.h +++ b/src/inc/Machine.h @@ -46,7 +46,7 @@ of the License or (at your option) any later version. #endif #else #define HOT __attribute__((hot)) -#if defined(__x86_64) +#if defined(__x86_64) && !defined(__INTEL_COMPILER) #define REGPARM(n) __attribute__((hot, regparm(n))) #else #define REGPARM(n) diff --git a/tests/examples/CMakeLists.txt b/tests/examples/CMakeLists.txt index 103c78be..e8c9fb40 100644 --- a/tests/examples/CMakeLists.txt +++ b/tests/examples/CMakeLists.txt @@ -23,7 +23,7 @@ macro(test_example TESTNAME SRCFILE) set_tests_properties(${TESTNAME} PROPERTIES TIMEOUT 3) endmacro() -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +if (${CMAKE_SYSTEM_NAME} STREQUAL ".*Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL ".*GNU") find_package(Freetype) if (${FREETYPE_FOUND}) include_directories(${FREETYPE_INCLUDE_DIRS}) diff --git a/tests/vm/CMakeLists.txt b/tests/vm/CMakeLists.txt index ee866de9..b41e73f8 100644 --- a/tests/vm/CMakeLists.txt +++ b/tests/vm/CMakeLists.txt @@ -29,7 +29,7 @@ if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_link_libraries(vm-test-direct vm-test-common) endif() -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") +if (${CMAKE_SYSTEM_NAME} STREQUAL ".*Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL ".*GNU") add_definitions(-fno-rtti -fno-exceptions) if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release") add_definitions(-DNDEBUG -fomit-frame-pointer)