{"action":"created","issue":{"url":"https://api.github.com/repos/fmtlib/fmt/issues/1478","repository_url":"https://api.github.com/repos/fmtlib/fmt","labels_url":"https://api.github.com/repos/fmtlib/fmt/issues/1478/labels{/name}","comments_url":"https://api.github.com/repos/fmtlib/fmt/issues/1478/comments","events_url":"https://api.github.com/repos/fmtlib/fmt/issues/1478/events","html_url":"https://github.com/fmtlib/fmt/issues/1478","id":538031507,"node_id":"MDU6SXNzdWU1MzgwMzE1MDc=","number":1478,"title":"cmake file is using incorrect tools for checking if a stymbol exists","user":{"login":"killerbot242","id":3847743,"node_id":"MDQ6VXNlcjM4NDc3NDM=","avatar_url":"https://avatars3.githubusercontent.com/u/3847743?v=4","gravatar_id":"","url":"https://api.github.com/users/killerbot242","html_url":"https://github.com/killerbot242","followers_url":"https://api.github.com/users/killerbot242/followers","following_url":"https://api.github.com/users/killerbot242/following{/other_user}","gists_url":"https://api.github.com/users/killerbot242/gists{/gist_id}","starred_url":"https://api.github.com/users/killerbot242/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/killerbot242/subscriptions","organizations_url":"https://api.github.com/users/killerbot242/orgs","repos_url":"https://api.github.com/users/killerbot242/repos","events_url":"https://api.github.com/users/killerbot242/events{/privacy}","received_events_url":"https://api.github.com/users/killerbot242/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2019-12-15T10:30:33Z","updated_at":"2019-12-17T14:07:00Z","closed_at":"2019-12-15T14:51:24Z","author_association":"NONE","body":"When I cmake configure the library as stand-alone I get : \r\n-- Looking for strtod_l - found\r\n\r\nHowever when I use it as a sub-project, it fails to find this.\r\n-- Looking for strtod_l - not found \r\n\r\nI think the cause is due to using the incorrect set of tool/function.\r\ninclude(CheckSymbolExists)  ==> check_symbol_exists()\r\n=====> this happens within the C compiler, while we are targeting a C++ library here, right ?\r\n\r\nWhen I adjust the CMakeLists.txt into : \r\ninclude(CheckCXXSymbolExists)\r\nif (WIN32)\r\n  check_cxx_symbol_exists(_strtod_l \"${strtod_l_headers}\" HAVE_STRTOD_L)\r\nelse ()\r\n  check_cxx_symbol_exists(strtod_l \"${strtod_l_headers}\" HAVE_STRTOD_L)\r\nendif ()\r\n\r\nthen it works as expected.\r\n\r\nproblems detected on linux, with gcc 7.4  (C++ standard did not matter, tried 11 and 17)\r\n\r\nReferences : \r\nhttps://cmake.org/cmake/help/latest/module/CheckCXXSymbolExists.html\r\nhttps://cmake.org/cmake/help/latest/module/CheckSymbolExists.html"},"comment":{"url":"https://api.github.com/repos/fmtlib/fmt/issues/comments/566555319","html_url":"https://github.com/fmtlib/fmt/issues/1478#issuecomment-566555319","issue_url":"https://api.github.com/repos/fmtlib/fmt/issues/1478","id":566555319,"node_id":"MDEyOklzc3VlQ29tbWVudDU2NjU1NTMxOQ==","user":{"login":"killerbot242","id":3847743,"node_id":"MDQ6VXNlcjM4NDc3NDM=","avatar_url":"https://avatars3.githubusercontent.com/u/3847743?v=4","gravatar_id":"","url":"https://api.github.com/users/killerbot242","html_url":"https://github.com/killerbot242","followers_url":"https://api.github.com/users/killerbot242/followers","following_url":"https://api.github.com/users/killerbot242/following{/other_user}","gists_url":"https://api.github.com/users/killerbot242/gists{/gist_id}","starred_url":"https://api.github.com/users/killerbot242/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/killerbot242/subscriptions","organizations_url":"https://api.github.com/users/killerbot242/orgs","repos_url":"https://api.github.com/users/killerbot242/repos","events_url":"https://api.github.com/users/killerbot242/events{/privacy}","received_events_url":"https://api.github.com/users/killerbot242/received_events","type":"User","site_admin":false},"created_at":"2019-12-17T14:07:00Z","updated_at":"2019-12-17T14:07:00Z","author_association":"NONE","body":"I did some more experiments, see the attached zip file for an stripped down CMakeLists.txt, and the one I added on top.\r\n\r\nThe top CMakeLists.txt is : \r\ncmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)\r\nproject(testfmt)\r\nadd_subdirectory(fmt-6.1.2)\r\n\r\nAnd the reduced fmt one is:\r\ncmake_minimum_required(VERSION 3.1.0)\r\n\r\n# Use newer policies if available, up to most recent tested version of CMake.\r\nif(${CMAKE_VERSION} VERSION_LESS 3.11)\r\n  cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})\r\nelse()\r\n  cmake_policy(VERSION 3.11)\r\nendif()\r\n\r\nproject(FMT CXX)\r\n\r\nset(strtod_l_headers stdlib.h)\r\n\r\ninclude(CheckSymbolExists)\r\ncheck_symbol_exists(strtod_l \"${strtod_l_headers}\" HAVE_STRTOD_L)\r\n\r\n\r\nwith the following cmake invocation (on either level):cmake -D CMAKE_BUILD_TYPE=Release -H. -Bbuild/Release\r\n\r\nIn fmt directory this leads to:\r\n-- The CXX compiler identification is GNU 7.4.1\r\n-- Check for working CXX compiler: /usr/bin/c++\r\n-- Check for working CXX compiler: /usr/bin/c++ -- works\r\n-- Detecting CXX compiler ABI info\r\n-- Detecting CXX compiler ABI info - done\r\n-- Detecting CXX compile features\r\n-- Detecting CXX compile features - done\r\n-- Looking for strtod_l\r\n-- Looking for strtod_l - found\r\n-- Configuring done\r\n-- Generating done\r\n\r\n====> found\r\n====> NOTE : no attempts made to look for C compiler\r\n\r\nHowever the top project did not specify a language (so it will try bot C and C++ : from cmake manual : By default C and CXX are enabled if no language options are given.), then the outcome is:-- The C compiler identification is GNU 7.4.1\r\n-- The CXX compiler identification is GNU 7.4.1\r\n-- Check for working C compiler: /usr/bin/cc\r\n-- Check for working C compiler: /usr/bin/cc -- works\r\n-- Detecting C compiler ABI info\r\n-- Detecting C compiler ABI info - done\r\n-- Detecting C compile features\r\n-- Detecting C compile features - done\r\n-- Check for working CXX compiler: /usr/bin/c++\r\n-- Check for working CXX compiler: /usr/bin/c++ -- works\r\n-- Detecting CXX compiler ABI info\r\n-- Detecting CXX compiler ABI info - done\r\n-- Detecting CXX compile features\r\n-- Detecting CXX compile features - done\r\n-- Looking for strtod_l\r\n-- Looking for strtod_l - not found\r\n-- Configuring done\r\n-- Generating done\r\n\r\n===> NOT found\r\n\r\nNow something interesting, let's adjust in the fmt CMakeLists.txt the project line into:\r\nproject(FMT CXX C)\r\nor even \r\nproject(FMT)\r\n\r\nthen we get : \r\n-- The CXX compiler identification is GNU 7.4.1\r\n-- The C compiler identification is GNU 7.4.1\r\n-- Check for working CXX compiler: /usr/bin/c++\r\n-- Check for working CXX compiler: /usr/bin/c++ -- works\r\n-- Detecting CXX compiler ABI info\r\n-- Detecting CXX compiler ABI info - done\r\n-- Detecting CXX compile features\r\n-- Detecting CXX compile features - done\r\n-- Check for working C compiler: /usr/bin/cc\r\n-- Check for working C compiler: /usr/bin/cc -- works\r\n-- Detecting C compiler ABI info\r\n-- Detecting C compiler ABI info - done\r\n-- Detecting C compile features\r\n-- Detecting C compile features - done\r\n-- Looking for strtod_l\r\n-- Looking for strtod_l - not found\r\n-- Configuring done\r\n-- Generating done\r\n\r\n===> NOT found\r\n\r\nSo the symbol is there, right, my system is not changing.\r\n\r\nWhat does this gives on your system with the older cmake you have ?\r\n\r\n\r\nIf it is optional and does not affect the functionality then why do we search for it, and next to that having consistent behavior is nice (sub project or master project should make no difference),\r\n\r\nAlthough it might be a C symbol, it needs to be looked for under the correct compiler, being here the C++ compiler, since that is the targeted one, and that is more or less what the cmake reference is saying about this symbol checking (see links in my original post).\r\n==> I am not sure if that is the correct way to interpret this so I am surely not stating it is like that.\r\n\r\nCurious on how it will turn out on your system .... ;-) \r\n[HAVE_STRTOD_L.tar.gz](https://github.com/fmtlib/fmt/files/3973632/HAVE_STRTOD_L.tar.gz)\r\n"}}
{"actor":{"display_login":"killerbot242"}}