As far as I remember I didn’t change anything in CMakeLists.txt, the problem was caused by the directory structure of my libtorch folder. My folder structure for libtorch was like below:

├── Home
│   ├── username
│      └── libtorch
│          └── libtorch
│                ├── bin
│                ├── include
│                ├── lib
│                ├── share
                  ........

After I changed the file structure as below, the built was completed successfully:

├── Home
│   ├── username
│      └── libtorch
│         ├── bin
│         ├── include
│         ├── lib
│         ├── share
            ........

Hope this would help.