Skip to content

Commit

Permalink
Merge branch 'develop' into improve_win_dev_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hsorby committed Feb 12, 2018
2 parents 4ac3dba + a94b197 commit 441ed37
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
16 changes: 15 additions & 1 deletion CMakeLists.txt
Expand Up @@ -107,7 +107,21 @@ hide_distracting_variables()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Find libxml2
find_package(LibXml2 REQUIRED)
set(HAVE_LIBXML2_CONFIG FALSE)
if (MSVC)
# If we want to use config packages (as a backup) on Windows with Visual Studio,
# we need to have two find_package calls and explicitly state that
# we wish to skip Module mode in the second call. This does change how we get
# information about include paths and such so we need to track how we found
# LibXml2.
find_package(LibXml2 QUIET)
if (NOT LIBXML2_FOUND)
find_package(LibXml2 REQUIRED CONFIG)
set(HAVE_LIBXML2_CONFIG TRUE)
endif ()
else ()
find_package(LibXml2 REQUIRED)
endif ()

# cellml library target
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src)
Expand Down
11 changes: 7 additions & 4 deletions src/CMakeLists.txt
Expand Up @@ -122,14 +122,17 @@ target_include_directories(cellml
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/api/libcellml/module>
$<INSTALL_INTERFACE:include/>
$<INSTALL_INTERFACE:include/libcellml/module>
${LIBXML2_INCLUDE_DIR}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
)

target_link_libraries(cellml PUBLIC ${LIBXML2_LIBRARIES})

target_compile_definitions(cellml PUBLIC ${LIBXML2_DEFINITIONS})
if(HAVE_LIBXML2_CONFIG)
target_link_libraries(cellml PUBLIC xml2)
else()
target_include_directories(cellml PUBLIC ${LIBXML2_INCLUDE_DIR})
target_link_libraries(cellml PUBLIC ${LIBXML2_LIBRARIES})
target_compile_definitions(cellml PUBLIC ${LIBXML2_DEFINITIONS})
endif()

set_target_properties(cellml PROPERTIES
CXX_STANDARD 11
Expand Down
14 changes: 11 additions & 3 deletions tests/CMakeLists.txt
Expand Up @@ -24,8 +24,6 @@ include(validator/tests.cmake)
include(variable/tests.cmake)
include(version/tests.cmake)

set(test_path)
list(APPEND test_path $ENV{PATH} $<TARGET_FILE_DIR:cellml>)
# Cycle through all the tests 'included' above
set(TEST_LIST)
foreach(TEST ${LIBCELLML_TESTS})
Expand All @@ -47,7 +45,17 @@ foreach(TEST ${LIBCELLML_TESTS})
# target_warnings_as_errors(${CURRENT_TEST})
# endif()

add_test(${CURRENT_CATEGORY}unit_${CURRENT_TEST} ${CURRENT_TEST})
add_test(NAME ${CURRENT_CATEGORY}unit_${CURRENT_TEST} COMMAND ${CURRENT_TEST})
if(MSVC)
if(HAVE_LIBXML2_CONFIG)
set_tests_properties(${CURRENT_CATEGORY}unit_${CURRENT_TEST}
PROPERTIES ENVIRONMENT "PATH=$<TARGET_FILE_DIR:cellml>\;$<TARGET_FILE_DIR:gtest_main>\;$<TARGET_FILE_DIR:xml2>")
else()
# The libxml2 dll must be on the path otherwise the tests will not be able to run.
set_tests_properties(${CURRENT_CATEGORY}unit_${CURRENT_TEST}
PROPERTIES ENVIRONMENT "PATH=$<TARGET_FILE_DIR:cellml>\;$<TARGET_FILE_DIR:gtest_main>")
endif()
endif()

list(APPEND TEST_LIST ${CURRENT_TEST})
unset(CURRENT_CATEGORY)
Expand Down
3 changes: 3 additions & 0 deletions tests/gtest-1.7.0/cmake/internal_utils.cmake
Expand Up @@ -66,6 +66,9 @@ macro(config_compiler_and_linker)
# Resolved overload was found by argument-dependent lookup.
set(cxx_base_flags "${cxx_base_flags} -wd4675")
endif()
if(MSVC_VERSION GREATER_EQUAL 1900 AND MSVC_VERSION LESS 1913)
set(cxx_base_flags "${cxx_base_flags} -wd4996")
endif()
set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
Expand Down

0 comments on commit 441ed37

Please sign in to comment.